views:

40

answers:

1

When I click the ListView in layout1, it will go to layout2 and show some imformation. But when I click the button I designed to back to layout1, I can't see the ListView. Just black background.

Here is the Button code:

Button backButton = (Button) findViewById(R.id.widget39);
backButton.setOnClickListener(new Button.OnClickListener()
    {
        public void onClick(android.view.View v) {
            setContentView(R.layout.layout1);
            myListView = (ListView) findViewById(R.id.ListView);
            myCursor = ToDoDB.select();
    }
 });
+1  A: 

You are not putting any data in your ListView. Hence, the ListView will be empty.

CommonsWare
But I added this:
Kooper
SimpleCursorAdapter adapter1 = new SimpleCursorAdapter(this,R.layout.list,myCursor,new String[]{DoDB._StudyUID},new int[]{R.id.listTextView1}); myListView.setAdapter(adapter1);
Kooper
Can't compiler :(
Kooper
You need to actually tell us what your errors are rather than just giving us "Can't compiler :(". In this case, though, you have at least one problem -- `this` is a `Button.OnClickListener`. You need to use `MyActivity.this`, where `MyActivity` is the name of your activity.
CommonsWare