它顯示一個空對象錯誤。 當我取卡RecylerView我們如何獲取卡片中的Onclick按鈕值recylerView
Process: com.softedge.visioneering.tfd, PID: 9884
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
at com.softedge.visioneering.tfd.adapters.MyOrdersAdapter$MyOrdersViewHolder$1.onClick(MyOrdersAdapter.java:138)
at android.view.View.performClick(View.java:5609)
This Is My Adapter and Button Code:
public class MyOrdersViewHolder extends RecyclerView.ViewHolder {
public TextView txtOrderDescription, txtOrderQuantity, txtOrderStatus, txtOrderDate, txtExpectedDate, txtCreatedBy,txtOrderStatus_Per;
String check;
public Button update_btwn;
public MyOrdersViewHolder(View convertView) {
super(convertView);
update_btwn=(Button) convertView.findViewById(R.id.status_update_button);
final FragmentManager fragmentManager = ((FragmentActivity) context).getSupportFragmentManager();
update_btwn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
id = (Integer) update_btwn.getTag();
fragmentManager.beginTransaction().replace(R.id.container, new Status_update_Fragment().newInstance()).addToBackStack(" ").commit();
//((FragmentActivity) context).getSupportFragmentManager().beginTransaction().
// remove(((FragmentActivity) context).getSupportFragmentManager().findFragmentById(R.id.container)).commit();
}
});
的按鈕值我想執行的按鈕的動作。 卡中的哪個位置RecylerView
您需要setTag權得到它之前.. – Srihari
我們是怎麼做的請告訴我 –
我只是想知道哪個按鈕卡在卡recylerView –