自分自身のレイアウトを持つ「activityCatalog」があり、この中に別のレイアウトの魔法使いがリストアイテムのレイアウトとして表示されます。 リスト項目のレイアウトには、テキストビューとボタンがあります。 "activityCatalog"からこのボタンを使用してリスト項目のテキストビューを変更しようとしましたが、nullポインタ例外が返されます。他のレイアウトのテキストビューのテキストを変更する
アイデア? すべての質問
アダプタを掲載: パブリッククラスProductCursorAdapterは、CursorAdapterを{
public ProductCursorAdapter(Context context, Cursor c) {
super(context, c, 0);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return LayoutInflater.from(context).inflate(R.layout.list_item, parent,false);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
TextView nameTextView = (TextView) view.findViewById(R.id.name);
TextView priceTextView = (TextView) view.findViewById(R.id.price);
TextView quantityTextView = (TextView) view.findViewById(R.id.quantity);
TextView idTextView = (TextView) view.findViewById(R.id.Id_View);
// Find the columns of pet attributes that we're interested in
int nameColumnIndex = cursor.getColumnIndex(ProductEntry.COLUMN_NAME);
int priceColumnIndex = cursor.getColumnIndex(ProductEntry.COLUMN_PRICE);
int quantityColumnIndex = cursor.getColumnIndex(ProductEntry.COLUMN_QUANTITY);
int idColumnIndex = cursor.getColumnIndex(ProductEntry._ID);
// Read the pet attributes from the Cursor for the current pet
String Name = cursor.getString(nameColumnIndex);
String Price = cursor.getString(priceColumnIndex);
String quantity = cursor.getString(quantityColumnIndex);
String id = cursor.getString(idColumnIndex);
// Update the TextViews with the attributes for the current pet
nameTextView.setText(Name);
priceTextView.setText(Price);
quantityTextView.setText(quantity);
idTextView.setText(id);
}
}
次のようなリストビュー項目にアクセスすることはできません。それをアダプタで行います。 – ADM
あなたの完全なコードを投稿して、明確に質問してください – Raja
私はアダプタでそれをしましたが、私はボタンにアクセスするために正確に知りません。 –