Reputation: 35
I create a XML layout :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="4dip"
android:paddingRight="4dip"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="24sp" />
</LinearLayout>
I want to fill this layout by below code :
package ir.smspeik.sms;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
public class MyListView extends ListActivity {
/** Called when the activity is first created. */
TextView selection;
String[] names;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listlayout);
names = new String[] { "sunday", "monday", "tuesday", "wednesday",
"thrusday", "friday", "saturday", };
this.setListAdapter(new ArrayAdapter<String>(this, android.R.layout.custom,
R.id.label, names));
selection = (TextView) findViewById(R.id.label);
}
public void onListItemClick(ListView parent, View v, int position, long id) {
selection.setText(names[position]);
}
}
I have two warnings and an error. warnings are in xml file : 1. This tag and its children can be replaced by one and a compound drawable 2. [Accessibility] Missing contentDescription attribute on image
error in MyListView 1. the eclipse doesn't know android.R.layout.custom
Upvotes: 0
Views: 223