我有一个应该显示可点击列表的片段。
该列表来自方法List<Location> getAllLocations()
。
-Element来自Location
数据库,如下所示:
id: 1
name: Example
description: A long Description
Geo: Latitude: 46.685984999999995 Longitude: 7.867318999999998
它应该只显示名称和描述。当我单击它时,它应该在 a 中打开DetailView
(此视图已完成并且可以工作)。
我如何实现这样的 ViewList?
片段代码
public class EditSectionFragment extends Fragment {
public EditSectionFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.edit_fragment, container,
false);
return view;
}
}
我已经尝试过
实现 ListAdapter。添加了一大堆方法并对此感到困惑。
public class EditSectionFragment extends Fragment implements ListAdapter {
public EditSectionFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.edit_fragment, container,
false);
return view;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return 0;
}
@Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return 0;
}
@Override
public int getItemViewType(int arg0) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(int arg0, View arg1, ViewGroup arg2) {
// TODO Auto-generated method stub
return null;
}
@Override
public int getViewTypeCount() {
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean hasStableIds() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isEmpty() {
// TODO Auto-generated method stub
return false;
}
@Override
public void registerDataSetObserver(DataSetObserver arg0) {
// TODO Auto-generated method stub
}
@Override
public void unregisterDataSetObserver(DataSetObserver arg0) {
// TODO Auto-generated method stub
}
@Override
public boolean areAllItemsEnabled() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isEnabled(int position) {
// TODO Auto-generated method stub
return false;
}
}