为root studio传递null给了我这个警告:
避免将null作为视图根传递(需要解析膨胀布局的根元素上的布局参数)
它显示为空值getGroupView.请帮忙.
public class ExpandableListAdapter extends BaseExpandableListAdapter {
private Context _context;
private List<String> _listDataHeader; // header titles
// child data in format of header title, child title
private HashMap<String, List<String>> _listDataChild;
public ExpandableListAdapter(Context context, List<String> listDataHeader,
HashMap<String, List<String>> listChildData) {
super();
this._context = context;
this._listDataHeader = listDataHeader;
this._listDataChild = listChildData;
}
@Override
public Object getChild(int groupPosition, int childPosititon) {
return this._listDataChild.get(this._listDataHeader.get(groupPosition))
.get(childPosititon);
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public …Run Code Online (Sandbox Code Playgroud) Avoid passing null as the view root当用nullas 膨胀视图时,我得到了lint警告parent,例如:
LayoutInflater.from(context).inflate(R.layout.dialog_edit, null);
Run Code Online (Sandbox Code Playgroud)
但是,视图是用作一个内容AlertDialog,使用setViewon AlertDialog.Builder,所以我不知道应该传递什么parent.
parent在这种情况下你认为应该是什么?
我有一个具有纵向主要布局的应用程序(它固定为肖像),并且有一个地方可以输入文本.我希望像横向方向的弹出窗口一样启动,背景图像模糊不清.我知道有一个弹出窗口小部件,但任何旋转文本编辑框的想法都会很棒.当键盘滑出时将其旋转为纵向视图(仅限文本框)也可以工作,就像在键盘滑块上显示带有文本框的新屏幕一样.
我可以使用PopupWindow而不是Dialog来调暗背景吗?我问这个是因为我正在使用Dialogs,但Dialog没有显示在点击的项目下面,并且PopupWindow我已经在项目下面显示了弹出窗口.
android dialog popupwindow android-dialog android-popupwindow
我想在弹出窗口打开后使背景变暗,并在关闭后恢复之前的所有内容。我已经搜索过谷歌并看到了一些教程。但我无法理解这怎么可能。这是我的 Java 代码:
public void displayPopupWindow() {
View layout = getLayoutInflater().inflate(R.layout.popup,null);
final PopupWindow popup = new PopupWindow(this);
popup.setContentView(layout);
popup.setOutsideTouchable(true);
popup.setFocusable(true);
popup.setWidth(400);
popup.setHeight(580);
popup.showAtLocation(layout, Gravity.CENTER, 0, 0);
popup.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
Button button = (Button) layout.findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View layout) {
popup.dismiss();
}
});
}
Run Code Online (Sandbox Code Playgroud)
这是我的弹出 xml 代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/colorPrimary"
android:id="@+id/popup"
>
Various views and button
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我现在该怎么办?
友.在我用过的一个项目中PopupWindow.我的问题是在查看popupwindow时,设计似乎很不舒服.所以我想调暗或模糊我的活动背景.我搜索了很多,但大多数答案似乎只是为了Dialog不PopupWindow.是否有可能在Android中查看时调暗我们的活动背景PopupWindaow.
提前致谢.