Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSara Assiaw
Courses Plus Student 324 PointsAction Bar not show for Android Studio 1.0
Am using Android Studio 1.0 for this project and the action bar is not show up for Edit Friends and Choose Recipient. Upon researching I learnt you have to extends ActionBarActivity for action bar to appear. Now my question is I have extends ActionBarActivity in the RecipientsActivity class and getting red colour error with the below:
- getListView()
- setListAdapter(adapter);
- .onListItemClick(l, v, position, id);
Your help will be appreciated.
Thanks.
5 Answers
Andre Kettschau
20,054 PointsI ran into the same problem, you cannot extend from ActionBarView and ListView at the same time. My solution was to declare the ListView as a member Variable:
protected ListView mListview;
in onCreate:
mListview = (ListView) findViewById(R.id.receipientsListView);
mListview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
With that in place you can replace "getListView()" with "mListview"
The id of your ListView has to bet set too (in the layout file)
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/receipientsListView"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"/>
Andre Kettschau
20,054 Pointschange getListView().setListAdapter(ArrayAdapter) to mListview.setListAdapter(ArrayAdapter)
and
onListItemClick(ListView,View,int,long) to mListview.onListItemClick(ListView,View,int,long)
Ian Z
14,584 Pointshey! i tried this but in mListview.setListAdapter(ArrayAdapter) the setListAdapter is marked red, is it ok to change to .setAdapter?
Miguel Fernandes
1,314 Pointssame problem here with setListAdapter(ArrayAdapter). mListView is a ListView, not a ListActivity.
Sara Assiaw
Courses Plus Student 324 PointsThank you for sharing. Am going to try in and let you know
Sara Assiaw
Courses Plus Student 324 PointsI tried and I got this error message and same error:
Error:(86, 29) error: cannot find symbol method getListView() Error:(89, 21) error: cannot find symbol method setListAdapter(ArrayAdapter<String>) Error:(147, 5) error: method does not override or implement a method from a supertype Error:(149, 14) error: cannot find symbol method onListItemClick(ListView,View,int,long) Error:(186, 29) error: cannot find symbol method getListView() Error:(187, 17) error: cannot find symbol method getListView()
Sara Assiaw
Courses Plus Student 324 PointsAny tips please!