私は、リストアクティビティー用のカスタムアダプターを作成して、各アクションごとに異なるイメージを表示しようとしています。次のエラーが発生しています。android:ListActivity、カスタムアダプター
Error: The method getView(int, View, ViewGroup) of type
ClientOperations.MyCustomAdapter must override or implement a supertype method
誰かが私を助けてくれますか?
public class ClientOperations extends ListActivity {
public class MyCustomAdapter extends ArrayAdapter<String> {
public MyCustomAdapter(Context context, int textViewResourceId, String[] objects) {
super(context, textViewResourceId, objects);
// TODO Auto-generated constructor stub
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
LayoutInflater inflater=getLayoutInflater();
View row=inflater.inflate(R.layout.clientoperations, parent, false);
TextView op=(TextView)row.findViewById(R.id.operation);
op.setText(operation[position]);
ImageView icon=(ImageView)row.findViewById(R.id.icon);
if (operation[position] == "Share"){
icon.setImageResource(R.drawable.filesharing);
} else if(operation[position] == "Remove"){
icon.setImageResource(R.drawable.remove);
} else if(operation[position] == "Exit"){
icon.setImageResource(R.drawable.logout);
} else {
icon.setImageResource(R.drawable.viewshare);
}
return row;
}
}
String username = null;
String[] operation = new String[] { "Share", "Servershare", "Usershare", "Myshare",
"Remove", "Exit"};
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.clientoperations);
Bundle extras = getIntent().getExtras();
if(extras !=null)
{
username = extras.getString("username");
}
// Use your own layout and point the adapter to the UI elements which
// contains the label
this.setListAdapter(new ArrayAdapter<String>(this, R.layout.clientoperations,
R.id.operation, operation));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
// Get the item that was clicked
Object o = this.getListAdapter().getItem(position);
String keyword = o.toString();
Toast.makeText(this, "You selected: " + keyword, Toast.LENGTH_LONG)
.show();
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView android:id="@+id/icon"
android:layout_height="wrap_content"
android:src="@drawable/icon"
android:layout_width="22px"
android:layout_marginTop="10px"
android:layout_marginRight="7px"
android:layout_marginLeft="7px">
</ImageView>
<TextView android:text="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25dp"
android:textStyle="bold"
android:typeface="sans"
android:id="@+id/operation"
android:layout_marginTop="10px">
</TextView>
</LinearLayout>