Android 在导航抽屉项目上,单击弹出窗口
Android 在导航抽屉项目上,单击弹出窗口,android,Android,@Override public void onNavigationDrawerItemSelected(int position) { switch(position) { case 0: mTitle = getString(R.string.history); fragment_ride_history = new ListView(this); popupWindow = new
@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;
}
}
我想开发一个导航抽屉,然后在导航栏上单击我想显示一个附加到特定导航项目的弹出窗口(导航抽屉必须保持打开状态)
如果有人实现了这一点,请提供链接
@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;
}
}
这是我的代码片段
@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;
}
}
在“onNavigationDrawerItemSelected”上显示“popupWindow”没有问题
@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;
}
}
我认为“setBackgroundDrawable”的问题是因为您的代码与我一起工作,所以我只是删除了setBackgroundDrawable
我补充说
@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;
}
}
fragment_ride_history.setBackgroundColor
测试是否首先不调用webservice
@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;
}
}
对于webservice,请尝试从AsyncTask调用它,或者您可以使用凌空库并在调用响应时显示popupwindow,以不显示空的listview。popupwindow.ShowAs下拉列表(anchorview,0,0,Gravity.RIGHT);一点。我正在查找图像链接中显示的视图。是的,仅用于显示弹出窗口是可以的,但我正在查找图像链接中的视图。ThnX您不需要关闭navigationDrawer并更新popupWindow.showAtLocation(新的LinearLayout(此),Gravity.END,10,10);更新(501500900);将新的LinearLayout(此)删除到抽屉布局,并更新x、y、heightYes的值,它应该像在可展开视图中一样附着到抽屉项目。
@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;
}
}