Android listView 创建之后 无法显示界面,打印发现getCount走了,返回值有数据,就是不走getView,求指点 20
Fragment界面@OverridepublicViewonCreateView(LayoutInflaterinflater,ViewGroupcontainer,B...
Fragment界面
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mContext = getActivity();
mWindowManager = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE);
contactFragment = (LinearLayout) inflater.inflate(R.layout.fragment_contact, null);
initView();getData();addData(map);
return super.onCreateView(inflater, container, savedInstanceState);
}
public void initView(){
contact_select_but.setOnClickListener(contact_select_but_OnClick);
sidrbar = (SideBar) contactFragment.findViewById(R.id.sidrbar);//快速搜索
mDialogText = (TextView) LayoutInflater.from(mContext).inflate(R.drawable.list_position, null);//弹出的大字母
listView = (ZrcListView) contactFragment.findViewById(R.id.country_lvcountry);
}
public Map<String, Map<String, Object>> getData(){}
public void addData(Map<String, Map<String, Object>> map){
contactAdapter = new ContactAdapter(mContext,map);
listView.setAdapter(contactAdapter);
contactAdapter.notifyDataSetChanged();
sidrbar.setListView(listView);
mDialogText.setVisibility(View.INVISIBLE);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,WindowManager.LayoutParams.TYPE_APPLICATION,WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,PixelFormat.TRANSLUCENT);
mWindowManager.addView(mDialogText,lp);
sidrbar.setTextView(mDialogText);
}
自定义Adapter
@SuppressWarnings("unchecked")
public ContactAdapter(Context mContext , Map<String, Map<String, Object>> map ) {
super();
this.mContext = mContext;
this.map = map;
this.mNicks = getNicks(this.map);
}
@Override
public int getCount() {
Log.e(TAG, "getCount-------------" + mNicks.length);
return mNicks.length;
}
@Override
public Object getItem(int position) {
Log.e(TAG, "getItem-------------" + mNicks[position]);
return mNicks[position];
} 展开
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mContext = getActivity();
mWindowManager = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE);
contactFragment = (LinearLayout) inflater.inflate(R.layout.fragment_contact, null);
initView();getData();addData(map);
return super.onCreateView(inflater, container, savedInstanceState);
}
public void initView(){
contact_select_but.setOnClickListener(contact_select_but_OnClick);
sidrbar = (SideBar) contactFragment.findViewById(R.id.sidrbar);//快速搜索
mDialogText = (TextView) LayoutInflater.from(mContext).inflate(R.drawable.list_position, null);//弹出的大字母
listView = (ZrcListView) contactFragment.findViewById(R.id.country_lvcountry);
}
public Map<String, Map<String, Object>> getData(){}
public void addData(Map<String, Map<String, Object>> map){
contactAdapter = new ContactAdapter(mContext,map);
listView.setAdapter(contactAdapter);
contactAdapter.notifyDataSetChanged();
sidrbar.setListView(listView);
mDialogText.setVisibility(View.INVISIBLE);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,WindowManager.LayoutParams.TYPE_APPLICATION,WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,PixelFormat.TRANSLUCENT);
mWindowManager.addView(mDialogText,lp);
sidrbar.setTextView(mDialogText);
}
自定义Adapter
@SuppressWarnings("unchecked")
public ContactAdapter(Context mContext , Map<String, Map<String, Object>> map ) {
super();
this.mContext = mContext;
this.map = map;
this.mNicks = getNicks(this.map);
}
@Override
public int getCount() {
Log.e(TAG, "getCount-------------" + mNicks.length);
return mNicks.length;
}
@Override
public Object getItem(int position) {
Log.e(TAG, "getItem-------------" + mNicks[position]);
return mNicks[position];
} 展开
1个回答
展开全部
然而问的最关键的getview居然没有=。=!
contactFragment = (LinearLayout) inflater.inflate(R.layout.fragment_contact, null);
initView();getData();addData(map);
//你这里不是该返回contactFragment吗?要不然界面显示不了.我还怀疑你getview返回的对不对
return super.onCreateView(inflater, container, savedInstanceState);
contactFragment = (LinearLayout) inflater.inflate(R.layout.fragment_contact, null);
initView();getData();addData(map);
//你这里不是该返回contactFragment吗?要不然界面显示不了.我还怀疑你getview返回的对不对
return super.onCreateView(inflater, container, savedInstanceState);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询