ListView is empty

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

ListView is empty

Postby E-Nature » Wed Nov 18, 2009 4:20 pm

:-(
I just could not find a solution here in the forum for my problem. I am trying for hours now but can't seem to make it work. as you might have guessed I am pretty new to Android.

In a nutshell:
I have a button. If this button gets touched I want to display a listview.

The button works and the listener also. But then I just get a black screen.

Here are my code snippets:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void onCreate(Bundle savedInstanceState) {
  2.  
  3.                 super.onCreate(savedInstanceState);
  4.  
  5.                 setContentView(R.layout.main);
  6.  
  7.  
  8.  
  9. [.... irrelevant code...]
  10.  
  11.  
  12.  
  13.         Button invokingButton = (Button)findViewById(R.id.btnShowGameList);
  14.  
  15.         invokingButton.setOnClickListener(new OnClickListener() {
  16.  
  17.                
  18.  
  19.                 public void onClick(View v) {
  20.  
  21.                         setContentView(R.layout.gamelist);
  22.  
  23.                 }
  24.  
  25.         });
  26.  
  27. }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


and the class of the listview looks like this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class GameList extends ListActivity {
  2.  
  3.  
  4.  
  5.         static final String[] COUNTRIES = new String[] { "Afghanistan", "Albania", "Algeria", "Zimbabwe" };
  6.  
  7.        
  8.  
  9.         @Override
  10.  
  11.         public void onCreate(Bundle savedInstanceState) {
  12.  
  13.                 super.onCreate(savedInstanceState);
  14.  
  15.                
  16.  
  17.                 setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, COUNTRIES));
  18.  
  19.                 getListView().setTextFilterEnabled(true);
  20.  
  21.                 setContentView(R.layout.gamelist);
  22.  
  23.         }
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31. }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


and gamelist.xml:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <TableLayout
  4.  
  5.  xmlns:android="http://schemas.android.com/apk/res/android"
  6.  
  7.  android:layout_width="wrap_content"
  8.  
  9.  android:layout_height="wrap_content" >
  10.  
  11. </TableLayout>
  12.  
  13.  
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


Please help, I'm at this for hours now :-(

Dominik
User avatar
E-Nature
Experienced Developer
Experienced Developer
 
Posts: 93
Joined: Mon Nov 16, 2009 3:39 pm

Top

Postby E-Nature » Wed Nov 18, 2009 4:49 pm

Hey all

okay I also tried to make this work with an Intent - same problem. I just get a black ListView :(

CheatDatabaseAndroid.java
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Button invokingButton = (Button) findViewById(R.id.btnShowGameList);
  2.  
  3.                 invokingButton.setOnClickListener(new OnClickListener() {
  4.  
  5.  
  6.  
  7.                         public void onClick(View v) {
  8.  
  9.                                 Intent explicitIntent = new Intent(CheatDatabaseAndroid.this, GameList.class);
  10.  
  11.                                 startActivity(explicitIntent);
  12.  
  13.                         }
  14.  
  15.                 });
Parsed in 0.035 seconds, using GeSHi 1.0.8.4



GameList.java is as listed above.

Any suggestions? The XML files are there and ought to be correct I think.
User avatar
E-Nature
Experienced Developer
Experienced Developer
 
Posts: 93
Joined: Mon Nov 16, 2009 3:39 pm

Postby E-Nature » Wed Nov 18, 2009 4:54 pm

OKAY, problem solved!!

the culprit was this line:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. getListView().setTextFilterEnabled(true);
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


after I commented it out the list appeared! :x
User avatar
E-Nature
Experienced Developer
Experienced Developer
 
Posts: 93
Joined: Mon Nov 16, 2009 3:39 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Exabot [Bot] and 1 guest