if your ListView
is inside fragment you cannot access it in activity by
findViewById(R.id.listview);
try to do all this inside onCreateView
of the fragment instead.
Question
Hej Community! After a long search I decides to ask by myself. :)
I got a problem with the SlidingMenu library from jeremyfeinstein.
If I set the ListView in a fragment and make an ArrayAdapter for that I get an Exception on the setadapter line.
ListView listview = (ListView) findViewById(R.id.listview);
String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
"Blackberry", "WebOS", "Ubuntu" };
ArrayList<String> list = new ArrayList<String>();
for (int i = 0; i < values.length; ++i) {
list.add(values[i]);
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, list);
listview.setAdapter(adapter);
Please help! And sorry for the noobish question :)
Solution
if your ListView
is inside fragment you cannot access it in activity by
findViewById(R.id.listview);
try to do all this inside onCreateView
of the fragment instead.
OTHER TIPS
You may do like this:
ListView listview = (ListView)getView().findViewById(R.id.listview);