[英]Extends in Android using listview and navigation drawer
I've got an activity with a listview so my extends
in my MainActivity is a ListActivity
like this: 我有一个带有列表视图的活动,因此我在MainActivity中的extends
是这样的ListActivity
:
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? 我可以将导航抽屉用于listview活动吗?
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);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.