2017-01-29 44 views
-2
public class RecyclerAdapterNew extends RecyclerView.Adapter<DataHolderNew> { 

    @Override 
    public DataHolderNew onCreateViewHolder(ViewGroup parent, int viewType) { 

     Context context = parent.getContext(); 
     LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
     View view = inflater.inflate(R.layout.table_values, parent, false); 
     return new DataHolderNew(view); 
    } 

    @Override 
    public void onBindViewHolder(DataHolderNew holder, int position) { 
     Intent intent=new Intent(); 
     intent.getExtras("transfer",);//i have to transfer the value of the 
     //textview by converting into int and transfer into another class 
     holder.table_value.setText("table values: "+(position+1)); 

    } 

    @Override 
    public int getItemCount() { 
     return 10; 
    } 
} 
+1

所以你的問題是實際? – pskink

+0

我想轉賬號碼。值給另一個由recyclerview顯示的類...我應該怎麼做? @pskink –

回答

0

您可以使用下面的調用/調用活動「 -

Intent intent = new Intent(this,CalledActivity.class); 
     intent.putExtra(NameKeyforvalue,value); ...... 

startActivity(intent) 

,並使用名爲/調用(接收)活動如下: -

variabletoholdvalue = getIntent().getStringExtra(NameKeyforValue); 

注意getIntExtra,! getLongExtra等...(有些需要默認,getStringExtra沒有)

0

public class RecyclerAdapterNew extends RecyclerView.Adapter {

@Override 
public DataHolderNew onCreateViewHolder(ViewGroup parent, int viewType) { 

    Context context = parent.getContext(); 
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    View view = inflater.inflate(R.layout.table_values, parent, false); 

    return new DataHolderNew(view); 
} 

@Override 
public void onBindViewHolder(DataHolderNew holder, int position) { 
    Intent intent=new Intent(); 

    int value = intent.getIntExtra("transfer",); 
    holder.table_value.setText("table values: "+(position+1)*value); 

} 



@Override 
public int getItemCount() { 
    return 10; 
} 

}

+0

這裏是第二課,我想將價值轉移到 –