我正在编写一个android代码,其中单击recyclerview上的按钮时,它应该将其定向到其他一些活动。程序应该将控制重定向到每个 recyclerview 项目的不同活动。我已成功将按钮添加到活动模板中,但是,我无法理解如何向每个按钮添加功能。我随函附上我已包含在该项目中的不同文件。如果有人可以指导我如何从这里继续,那将非常有帮助。
ProductPage1.java
package com.agnik.example.myapplication4;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.os.Bundle;
import java.util.ArrayList;
public class ProductPage1 extends AppCompatActivity {
private RecyclerView mRecyclerView;
private RecyclerView.Adapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;
@Overrid
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_product_page1);
ArrayList<ExampleItem> exampleList = new ArrayList<>();
exampleList.add(new ExampleItem(R.drawable.mickeymouse, "Line1" , "Line2"));
exampleList.add(new ExampleItem(R.drawable.donalduck, "Line3" , "Line4"));
exampleList.add(new ExampleItem(R.drawable.popey, "Line5" , "Line6"));
exampleList.add(new ExampleItem(R.drawable.mickeymouse, "Line1" , "Line2"));
exampleList.add(new ExampleItem(R.drawable.donalduck, "Line3" , "Line4"));
exampleList.add(new ExampleItem(R.drawable.popey, "Line5" , "Line6"));
exampleList.add(new ExampleItem(R.drawable.mickeymouse, "Line1" , "Line2"));
exampleList.add(new ExampleItem(R.drawable.donalduck, "Line3" , "Line4"));
exampleList.add(new ExampleItem(R.drawable.popey, "Line5" , "Line6"));
exampleList.add(new ExampleItem(R.drawable.mickeymouse, "Line1" , "Line2"));
exampleList.add(new ExampleItem(R.drawable.donalduck, "Line3" , "Line4"));
exampleList.add(new ExampleItem(R.drawable.popey, "Line5" , "Line6"));
}
}
慕少森
明月笑刀无情
跃然一笑
慕斯王
相关分类