skip to Main Content

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.

enter image description here

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


  1. First of all, you need to attach your view in the adapter file, and then attach setOnClickListener() to the TextView and the other views, you want to clickable, and then inside the method of each view, perform task by using intent.

    Login or Signup to reply.
  2. 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

    public static class ViewHolder extends RecyclerView.ViewHolder {
            private final TextView textView;
    
            public ViewHolder(View v) {
                super(v);
                // Define click listener for the ViewHolder's View.
                v.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.d(TAG, "Element " + getAdapterPosition() + " clicked.");
                    }
                });
                textView = (TextView) v.findViewById(R.id.textView);
            }
    
            public TextView getTextView() {
                return textView;
            }
        }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search