Layout Problems in Listview

uae4ever

New Member
I have problem design wise. I am looking to display two pictures hortizontally inside of one row in a listView. like this:\[code\] TextView ImageView ImageView\[/code\]I am looking to see if i can use just an xml or do i have to consider using a different view altogether. I have Listview and a custom row xml through a baseadapter. see code for details\[code\] public class MyCustomBaseAdapter extends BaseAdapter { private Integer[] imgid = { R.drawable.up2, R.drawable.up3, R.drawable.up4, R.drawable.up5, R.drawable.up6, R.drawable.up7, R.drawable.up8, R.drawable.up9, R.drawable.down2, R.drawable.down3, R.drawable.down4, R.drawable.down5, R.drawable.down6, R.drawable.down7, R.drawable.down8, R.drawable.down9 }; private static ArrayList<DisplayResults> searchArrayList; private LayoutInflater mInflater; public MyCustomBaseAdapter(Context context, List<DisplayResults> list) { searchArrayList = (ArrayList<DisplayResults>) list; mInflater = LayoutInflater.from(context); } public int getCount() { return searchArrayList.size(); } public Object getItem(int position) { return searchArrayList.get(position); } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.list_row, null); holder = new ViewHolder(); //holder.txtName = (TextView) ` convertView.findViewById(R.id.ServiceName); holder.imgPhoto = (ImageView) convertView.findViewById(R.id.Up); //holder.imgPhoto2= (ImageView) convertView.findViewById(R.id.Down); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } //holder.txtName.setText(searchArrayList.get(position).getName()); holder.imgPhoto.setImageResource(imgid[searchArrayList.get(position).getImageNumber()]); System.out.println(searchArrayList.get(position).getImageNumber()); //holder.imgPhoto2.setImageResource(imgid[searchArrayList.get(position).getImageNumber2()]); return convertView; } static class ViewHolder { TextView txtName; ImageView imgPhoto; //ImageView imgPhoto2; } } public class satDataFrag extends Fragment { Data datas; ListView listView; LayoutInflater inflaterT; public satDataFrag(Data data) { this.datas=data; } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.sat, container, false); inflaterT = inflater; listView = (ListView) view.findViewById(R.id.listSat); //ImageView imgView; //imgView = (ImageView) view.findViewById(R.id.icon); List<DisplayResults> List = new ArrayList<DisplayResults>(); DisplayResults temp= new DisplayResults(); for(int i=0; i<datas.features.size(); i++) { if(datas.features.get(i).attributes.ServiceTyp.equalsIgnoreCase("Satellite")) { temp.setName(datas.features.get(i).attributes.dbANAME); temp.setImageNumber(upKey(datas.features.get(i).attributes.maxADUP)); temp.setImageNumber2(downKey(datas.features.get(i).attributes.maxADDOWN)); List.add(temp); } } //ArrayAdapter<Integer> adapter = new ArrayAdapter<Integer>(getActivity(), // R.layout.list_row, List); listView.setAdapter(new MyCustomBaseAdapter(getActivity(), List)); return view; } public Integer upKey (String max) { if(max.equalsIgnoreCase("2")) { return 0; } else if(max.equalsIgnoreCase("3")) { return 1; } else if(max.equalsIgnoreCase("4")) { return 2; } else if(max.equalsIgnoreCase("5")) { return 3; } else if(max.equalsIgnoreCase("6")) { return 4; } else if(max.equalsIgnoreCase("7")) { return 5; } else if(max.equalsIgnoreCase("8")) { return 6; } else if(max.equalsIgnoreCase("9")) { return 7; } else { return 7; } } public Integer downKey (String max) { if(max.equalsIgnoreCase("2")) { return 8; } else if(max.equalsIgnoreCase("3")) { return 9; } else if(max.equalsIgnoreCase("4")) { return 10; } else if(max.equalsIgnoreCase("5")) { return 11; } else if(max.equalsIgnoreCase("6")) { return 12; } else if(max.equalsIgnoreCase("7")) { return 13; } else if(max.equalsIgnoreCase("8")) { return 14; } else if(max.equalsIgnoreCase("9")) { return 15; } else { return 7; } }} custom_row.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:eek:rientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/ServiceName" android:text=""/> <ImageView android:id="@+id/Up" android:layout_gravity="left" android:layout_width="match_parent" android:layout_height="wrap_content" /> <ImageView android:id="@+id/Down" android:layout_gravity="left" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout>\[/code\]
 
Top