나는 자신의 레이아웃을 가진 "activityCatalog"를 가지고 있으며,이 중 다른 레이아웃 마녀는 목록 항목 레이아웃입니다. 목록 항목 레이아웃에는 텍스트보기와 버튼이 있습니다. 나는 액티비티를 시도하고 "activityCatalog"에서이 버튼을 사용하여 목록 항목의 텍스트 뷰를 변경하지만 널 포인터 예외가 다시 발생합니다.다른 레이아웃의 텍스트 뷰에서 텍스트 변경
아이디어가 있으십니까? 나에게 모든 질문에
물어 어댑터 : 공용 클래스 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
어댑터를 사용했지만 버튼에 정확히 액세스 할 수 없습니다. –