我是android开发的新手.我正在尝试构建一个带有标签的应用程序(通过片段添加).在其中一个片段中,我试图显示一个列表.这个列表已经使用我从ArrayAdapter扩展的ListAdapter填充,并且我重载了getView()方法.这是我的片段
public class tabcontentActivity extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (container == null) {
return null;
}
View v = (LinearLayout) inflater.inflate(R.layout.tablayout, container,
false);
ListView lv = (ListView) v.findViewById(R.id.listview1);
ListViewAdapter adapter = new ListViewAdapter(container.getContext(),
android.R.layout.simple_list_item_1, R.id.textview1);
adapter.notifyDataSetChanged();
lv.setAdapter(adapter);
return v;
}
}
Run Code Online (Sandbox Code Playgroud)
这就是我实现ListAdapter的方法
public class ListViewAdapter extends ArrayAdapter {
Context context1;
public ListViewAdapter(Context context,int resource, int textViewResourceId) {
super(context,resource,textViewResourceId);
this.context1 = context;
System.out.println("here aswell!!!!!!");
// TODO Auto-generated constructor stub
}
public View getView(int …Run Code Online (Sandbox Code Playgroud) android android-arrayadapter android-layout android-fragments