如果它们之间有一个活动,我想通过意图发送选定的数据

时间:2018-12-06 12:54:18

标签: android

$this->db->select("
    $table_1.id AS table_1_id,
    $table_1.whatever AS table_1_whatever,
    $table_2.id AS table_2_id,
    $table_2.whatever AS table_2_whatever,
    $table_3.id AS table_3_id,
    $table_3.whatever AS table_3_whatever,
    $table_4.id AS table_4_id,
    $table_4.whatever AS table_4_whatever,
");
$this->db->join($table_2, "$table_2.id = $table_1.table_2_id", 'left');
$this->db->join($table_3, "$table_3.id = $table_1.table_3_id", 'left');
$this->db->join($table_4, "$table_4.id = $table_1.table_4_id", 'left');

// holder.timedate.setText(Integer.toString(currItem.getUniqueid()));

@Override
public void onBindViewHolder(LiveMatchViewHolder holder, final int position) {


    liveMatchPOJO  currItem = liveMatches.get(position);


    holder.tvTeam1.setText(currItem.getTeam1());
    holder.tvTeam2.setText(currItem.getTeam2());

这是我的第一个代码,通过它我发送Intent,如何在第二个适配器上接收它

我如何在第二个适配器上接收它

@Override     public void onBindViewHolder(ViewHolderholder,int位置){

    if (prevPos < position) {
        //downwards
        AnimUtil.animate(holder, true);
    }else{
        //upwards
        AnimUtil.animate(holder, false);
    }

    holder.itemView.setOnClickListener(v -> {

        final Intent i;
               i = new Intent(context, Cricket_Categorie.class);
               i.putExtra("unique_id", liveMatches.get(position).getUniqueid());
               i.putExtra("matchStarted", liveMatches.get(position).getMatchStarted());
               i.putExtra("team1",liveMatches.get(position).getTeam1());
               i.putExtra("team2",liveMatches.get(position).getTeam2());
               context.startActivity(i);




    });

    prevPos = position;
}

我如何在此处接收文本,因为我需要通过此处将文本发送至第三个活动

2 个答案:

答案 0 :(得分:0)

您可以将文本发送到第二个活动,将其存储在某个变量中,并在需要时从第二个活动发送到第三个活动。

答案 1 :(得分:0)

如果要通过意图传递数据,则必须将数据传递给第二个活动,然后从第二个活动传递到第三个活动,如下所示:

Intent intent = new Intent(Activity1.this, Activity2.class);
intent.putExtra("EXTRA_DATA", data);
startActivity(intent);

然后在第二个活动中得到这样

String data= getIntent().getStringExtra("EXTRA_DATA");

然后传递到第三项活动,如下所示:

Intent intent = new Intent(Activity2.this, Activity3.class);
intent.putExtra("EXTRA_DATA", data);
startActivity(intent);