Skip to content

Instantly share code, notes, and snippets.

@krby
Created August 1, 2015 05:58
Show Gist options
  • Save krby/5b71da6876d81bf1b8e0 to your computer and use it in GitHub Desktop.
Save krby/5b71da6876d81bf1b8e0 to your computer and use it in GitHub Desktop.
TestClass.java
package com.example.choy.tdprotonewcon;
import android.app.Activity;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.RelativeLayout;
import android.widget.TextView;
import org.w3c.dom.Text;
public class ActivityTest extends Activity {
public static RelativeLayout rl;
public static TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_activity_test);
rl = (RelativeLayout) findViewById(R.id.layout);
tv = (TextView) findViewById(R.id.text);
// rl.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
// TextView textView = new TextView(getApplicationContext());
// textView.setText("dssfd");
// rl.addView(textView);
// setContentView(rl);
}
public void onClick(View view){
TestClass test = new TestClass();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_activity_test, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
package com.example.choy.tdprotonewcon;
import android.util.Log;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
/**
*r
*/
public class TestClass extends ActivityTest{
RelativeLayout relativeLayout;
ImageView img1;
public TestClass(){
relativeLayout = ActivityTest.rl;
// TextView textView = ActivityTest.tv;
// textView.setText(" " + getApplicationContext());
// Log.d(getApplicationContext());
img1 = new ImageView(getApplicationContext());
// img1.setImageResource(R.drawable.testtowerslot);
// relativeLayout.addView(img1);
// setContentView(relativeLayout);
// img1.getLayoutParams().width = 50;
// img1.getLayoutParams().height = 50;
//
// int random = (int )(Math.random() * 500 + 1);
// img1.setX(random);
// img1.setY(500);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment