使用Listview滑动菜单

时间:2014-02-17 07:19:01

标签: android list view menu sliding

我实际上正在使用Jfeinstein10提供的SlidingMenu,我正在使用一个以活动为后台的.xml。发生这种情况,我想使用ListView,我在后面的视图中从xml读取到此活动,但是,看起来滑动菜单只需要.xml文件并且不要调用活动。我该怎么办?

    public class MainActivity extends SlidingFragmentActivity {
    @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Log.e("TESTLOG", " ATIVIDADE 1 onCreate()");



    setBehindContentView(R.layout.activity_android_list_view_activity);
    getSlidingMenu().setMode(SlidingMenu.LEFT_RIGHT);
    getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
    getSlidingMenu().setFadeDegree(0.35f);
    getSlidingMenu().setSecondaryMenu(R.layout.activity_emergency);
    getSlidingMenu().setShadowWidthRes(R.dimen.shadow_width);
    getSlidingMenu().setShadowDrawable(R.drawable.shadow);
    getSlidingMenu().setBehindOffsetRes(R.dimen.slidingmenu_offset);
    getSlidingMenu().setSecondaryShadowDrawable(R.drawable.shadowright);

这是我想要在滑动菜单上的xml的活动:

    public class AndroidListViewActivity extends ListActivity {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_favorites);
            String[] questions = getResources().getStringArray(R.array.q1);

    this.setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, R.id.label, questions));

    ListView lv = getListView();


    lv.setOnItemClickListener(new OnItemClickListener() {
      public void onItemClick(AdapterView<?> parent, View view,
          int position, long id) {

          String product = ((TextView) view).getText().toString();

          Intent i = new Intent(getApplicationContext(), SingleListItem.class);
          // sending data to new activity
          i.putExtra("product", product);
          startActivity(i);

      }
    });
}
   }

如果我只是调用此活动,ListView可以正常工作,但不能通过Sliding菜单调用。

谢谢!

0 个答案:

没有答案