I got a problem with this code:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.list_mobile, parent, false);
TextView textView = (TextView) rowView.findViewById(R.id.label);
ImageView imageView = (ImageView) rowView.findViewById(R.id.logo);
textView.setText(values[position]);
// Change icon based on name
String s = values[position];
System.out.println("s = "+s);
System.out.println("Results = "+name[2].toString());
for (int i = 0; i < name.length; i ++){
if (s.equals(name[i])) {
imageView.setImageDrawable(loadImageFromURL("http://10.0.0.117/test/"+s+".jpg", "iOS"));
}
}
return rowView;
}
And this is my XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp" >
<ImageView
android:id="@+id/logo"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:contentDescription="@string/desc"
android:src="@drawable/windowsmobile_logo" >
</ImageView>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/logo"
android:layout_marginBottom="16dp"
android:layout_toRightOf="@+id/logo"
android:text="@+id/label"
android:textSize="20dp" />
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" >
<Button
android:id="@+id/btn_zoeken"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/txt_zoeken"
android:text="@string/Zoeken" />
<EditText
android:id="@+id/txt_zoeken"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10" >
<requestFocus />
</EditText>
</RelativeLayout>
</RelativeLayout>
I got this problem:
I got a list, and at the bottom of the screen their should always be an EditText
and a button
. But when I add this in the layout and start the app, it places the EditText
and the button
at every row
, see Pictures:
This is how it is (bad):
This is how it should be:
I got in the layout a RelativeLayout
in a RelativeLayout
, because I hoped it would fix this problem, but it didn't.
Please be aware, I make a list in a relative layout, so I don't use a ListView.
Anyone got a solution or a suggestion how to fix this?
I hope my question is clear.
Thanks already, Bigflow
Edit 1:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.inflater, parent, false);
TextView textView = (TextView) rowView.findViewById(R.id.label);
ImageView imageView = (ImageView) rowView.findViewById(R.id.logo);
Button btn_zoeken = (Button) rowView.findViewById(R.id.button1);
textView.setText(values[position]);
// Change icon based on name
String s = values[position];
System.out.println("s = "+s);
System.out.println("Results = "+name[2].toString());
for (int i = 0; i < name.length; i ++){
if (s.equals(name[i])) {
imageView.setImageDrawable(loadImageFromURL("http://10.0.0.117/test/"+s+".jpg", "iOS"));
}
}
return rowView;
}