Good day! I have been solving this problem for a long time, there is a recyclerview that receives data through firebase. How to make sure that when you click the TextView is sent to the site or when you click on the phone you can immediately call the number. When I click, nothing happens.
in the manifest, too, nothing ordinary
Adapter
public class FirebaseViewHolder extends RecyclerView.ViewHolder {
public TextView teamone, teamtwo;
public ImageView image;
public ImageView image2;
@Keep
public FirebaseViewHolder(@NonNull View itemView) {
super(itemView);
teamone = itemView.findViewById(R.id.teamone);
// teamtwo = itemView.findViewById(R.id.teamthree);
image = itemView.findViewById(R.id.image);
image2 = itemView.findViewById(R.id.image2);
}
}
end window
public class Main2Activity extends AppCompatActivity {
//доработать активити маин2 лайоут
private TextView teamone;
private TextView teamthree;
private TextView adress;
private TextView desq;
private TextView fio;
private TextView sayt;
private TextView telegram;
private TextView teamtwo;
private TextView opisaniye;
private TextView oriyentir;
private ImageView image1;
private ImageView image2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.rowtest);
teamone = (TextView) findViewById(R.id.teamone);
teamthree = (TextView) findViewById(R.id.teamthree);
adress = (TextView) findViewById(R.id.adress);
desq = (TextView) findViewById(R.id.desq1);
fio = (TextView) findViewById(R.id.fio);
sayt = (TextView) findViewById(R.id.sayt);
telegram = (TextView) findViewById(R.id.telegram);
//teamtwo = (TextView) findViewById(R.id.teamtwo);
opisaniye = (TextView) findViewById(R.id.opisaniye);
oriyentir = (TextView) findViewById(R.id.oriyentir);
image1 = (ImageView) findViewById(R.id.image1);
image2 = (ImageView) findViewById(R.id.image2);
Intent intent = getIntent();
String img = intent.getStringExtra("image");
Picasso.get().load(img).into(image1);
Intent intent1 = getIntent();
String img2 = intent.getStringExtra("image2");
Picasso.get().load(img2).into(image2);
teamone.setText(getIntent().getStringExtra("teamone"));
teamthree.setText(getIntent().getStringExtra("teamthree"));
adress.setText(getIntent().getStringExtra("adress"));
desq.setText(getIntent().getStringExtra("desq1"));
fio.setText(getIntent().getStringExtra("fio"));
sayt.setText(getIntent().getStringExtra("sayt"));
telegram.setText(getIntent().getStringExtra("telegram"));
// teamtwo.setText(getIntent().getStringExtra("teamtwo"));
opisaniye.setText(getIntent().getStringExtra("opis"));
oriyentir.setText(getIntent().getStringExtra("or"));
// Intent intent = getIntent();
String teamone = getIntent().getStringExtra("teamone");
String teamthree = getIntent().getStringExtra("teamthree");
String adress = getIntent().getStringExtra("adress");
String desq = getIntent().getStringExtra("desq1");
String fio = getIntent().getStringExtra("fio");
String sayt = getIntent().getStringExtra("sayt");
String telegram = getIntent().getStringExtra("telegram");
// String teamtwo = getIntent().getStringExtra("teamtwo");
String opisaniye = getIntent().getStringExtra("opis");
String oriyentir = getIntent().getStringExtra("or");
Log.i("OUR VALUE" , teamone);
Log.i("OUR VALUE 2" , teamthree);
Toast.makeText(this, "" + teamone , Toast.LENGTH_SHORT).show();
}
}
2
Answers
First of all, you need to attach your view in the adapter file, and then attach
setOnClickListener()
to theTextView
and the other views, you want to clickable, and then inside the method of each view, perform task by usingintent
.You need to create a customadapter where you set the
setOnClickListner()
on the views you need.Check out the example on github on how to implement recyclerview
https://github.com/android/views-widgets-samples/tree/main/RecyclerView/Application/src/main/java/com/example/android/recyclerview
This is the customadapter method where you set the listner