相关疑难解决方法(0)

避免将null作为视图根传递(需要解析膨胀布局的根元素上的布局参数)

为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)

android warnings android-layout layout-inflater

218
推荐指数
6
解决办法
8万
查看次数

Android:自定义ListAdapter扩展BaseAdapter在应用程序启动时崩溃

从本地数据库中提取数据,然后使用游标进行映射.自定义适配器显示类似于ListView的数据.在从DB添加/删除项目时,应该刷新适配器.下面尝试的解决方案在启动时崩溃了应用程序.有什么建议?

提前致谢

 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   View v = convertView;
   ViewGroup p = parent;            
   if (v == null) {
     LayoutInflater vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     v = vi.inflate(R.layout.items_row, p);
   }
   int size = mAdapter.getCount();
   Log.d(TAG, "position " + position + " Size " + size);
   if(size != 0){
     if(position < size) return mAdapter.getView(position, v, p);
     Log.d(TAG, "-position " + position + " Size " + size);
   }
   return null;
 }
Run Code Online (Sandbox Code Playgroud)

例外:

03-23 00:14:10.392: ERROR/AndroidRuntime(718): java.lang.UnsupportedOperationException: addView(View, …
Run Code Online (Sandbox Code Playgroud)

android

18
推荐指数
2
解决办法
1万
查看次数