我有一个带有多列的列表视图,其中每一行都有几个文本视图。在每行中包括两个文本视图,带有orientation="vertical"
.
在 xml 文件中,我可以设置每个 textview 的标签。然而,每个 textview 的这个标签在每一行中都是相等的。
如何设置每个文本视图的标签?id 也会出现同样的问题。第一排没问题。问题出在以下行中。
我放了一个带有示例的图像。
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
ViewGroup rootView = (ViewGroup)inflater.inflate(R.layout.fragment_screen_slide_page, container,false);
lv = (ListView)rootView.findViewById(android.R.id.list);
ArrayList<HashMap<String, String>> mylistData =
new ArrayList<HashMap<String, String>>();
String[] columnTags = new String[] {"hour","col1", "col2", "col3","col4", "col5", "col6","col7", "col8", "col9","col10", "col11", "col12","col13","col14"};
int[] columnIds = new int[] {R.id.tv_list_item1,R.id.tv_listRow_item1, R.id.tv_listRow_item2, R.id.tv_listRow_item3,R.id.tv_listRow_item4, R.id.tv_listRow_item5, R.id.tv_listRow_item6,R.id.tv_listRow_item7, R.id.tv_listRow_item8, R.id.tv_listRow_item9,R.id.tv_listRow_item10, R.id.tv_listRow_item11, R.id.tv_listRow_item12,R.id.tv_listRow_item13, R.id.tv_listRow_item14};
for(int i=0; i<24; i++)
{
HashMap<String,String> map = new HashMap<String, String>();
for(int j=0; j<15; j++)
{
if(j==0){
map.put("hour", "0"+i+":00");
if(i<10){
map.put("hour", "0"+i+":00");
}
else
map.put("hour", i+":00");
}
else if(j>0){
map.put(columnTags[j], "row”+i+”col"+j);
}
}
mylistData.add(map);
}
SimpleAdapter arrayAdapter =
new SimpleAdapter(getActivity(), mylistData, R.layout.sechedule_list_row,
columnTags , columnIds);
lv.setAdapter(arrayAdapter);