在导航抽屉项目上单击弹出窗口

时间:2016-02-10 12:12:33

标签: android

enter image description here

我想开发一个导航抽屉和onNavItemClick我想要显示一个附加到particullar nav Item的弹出窗口(导航抽屉必须保持打开状态) 如果有人实现了这一点,请提供链接。

这是我的代码段。

@Override
public void onNavigationDrawerItemSelected(int position) {

    switch(position)
    {

        case 0:
            mTitle = getString(R.string.history);
            fragment_ride_history = new ListView(this);
            popupWindow = new PopupWindow(
                    fragment_ride_history,
                    ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);
            popupWindow.setOutsideTouchable(true);
            popupWindow.setFocusable(true);
        popupWindow.setBackgroundDrawable(newBitmapDrawable());
            popupWindow.showAtLocation(new LinearLayout(this), Gravity.END, 10, 10);
            popupWindow.update(50, 50, 1500, 900);
            popupWindow.setContentView(fragment_ride_history);
            // this is to call webservice and append the data on listview
            getData(1);
            fragment_ride_history.setOnScrollListener(new 
            break;
   }
}

1 个答案:

答案 0 :(得分:0)

“onNavigationDrawerItemSelected”上显示“popupWindow”没有问题

我认为“setBackgroundDrawable”上的问题是因为你的代码与我合作我只是删除了setBackgroundDrawable 我添加了

fragment_ride_history.setBackgroundColor

首先测试是否没有调用webservice

对于webservice尝试从AsyncTask调用它,或者你可以使用volley lib并在调用时显示popupwindow,不要显示空列表视图。