Reputation: 1402
I've got an activity with a listview so my extends
in my MainActivity is a ListActivity
like this:
public class MainActivity extends ListActivity{
I want implement the new Navigation Drawer but i saw that the extends is this:
public class MainActivity extends ActionBarActivity {
How can i solve? Can i use the navigation drawer with a listview activity?
Upvotes: 1
Views: 1852
Reputation: 13731
Something like this
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fastScrollEnabled="true"
/>
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:cacheColorHint="#00000000"
android:choiceMode="singleChoice"
android:divider="@drawable/menu_list_divider"
android:background="@color/very_dark_gray"/>
</android.support.v4.widget.DrawerLayout>
Activity
public class YourActivity extends ActionBarActivity{
private ListView list;
private ArrayAdapter adapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_view);
list = (ListView) findViewById(R.id.list);
adapter = new ArrayAdapter...
list.setAdapter(adapter);
}
}
Upvotes: 2
Reputation: 3028
Yes, it's possible to implement lists without extending ListActivity
. Have a look at this article. It shows an example of lists without the ListActivity
.
Upvotes: 0