Layout does not show up after Activity launch
Posted
by
Peter
on Stack Overflow
See other posts from Stack Overflow
or by Peter
Published on 2012-08-28T09:30:51Z
Indexed on
2012/08/28
9:38 UTC
Read the original article
Hit count: 519
I have an activity which invokes an onItemClick and launches another activity. This activity has a static layout(for testing purposes), but only thing I see is black(I even set the text color to white to check it out).
My listener
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
//create new intent
Intent item = new Intent(getApplicationContext(), Item.class);
// Close all views before launching logged
//item.putExtra("name", ((TextView)arg1).getText());
//item.putExtra("uid", user_id);
item.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(item);
// Close Login Screen
onPause();
}
});
My activity is here(not much to do it just launches the layout)
public class Item extends Activity{
protected SQLiteDatabase myDB=null;
protected String name;
protected int uid;
TextView yeart,year,itemname,comment,commentt,value,valuet,curr,currt;
protected void onStart(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.herp);
/*name=getIntent().getStringExtra("name");
uid=Integer.parseInt(getIntent().getStringExtra("uid"));
itemname=(TextView) findViewById(R.id.itemName);//itemname.setText(name);
year=(TextView) findViewById(R.id.itemYear);
yeart=(TextView) findViewById(R.id.year);
comment=(TextView) findViewById(R.id.itemComments);
commentt=(TextView) findViewById(R.id.comments);
curr=(TextView) findViewById(R.id.itemcurrent);
currt=(TextView) findViewById(R.id.current);
value=(TextView) findViewById(R.id.itemValue);
valuet=(TextView) findViewById(R.id.value);*/
Database openHelper = new Database(this);
myDB = openHelper.getReadableDatabase();
myDB=SQLiteDatabase.openDatabase("data/data/com.example.login2/databases/aeglea", null, SQLiteDatabase.OPEN_READONLY);
}}
And finally my XML layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/itemName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="asdasd"
android:gravity="center"
android:layout_marginBottom="10px"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff" />
<TextView
android:id="@+id/current"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Current"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="@+id/itemcurrent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="asdasd" />
<TextView
android:id="@+id/year"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Year"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="@+id/itemYear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="asdasd" />
<TextView
android:id="@+id/value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Value"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="@+id/itemValue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="@+id/comments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Comments"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="@+id/itemComments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
© Stack Overflow or respective owner