如何将可变字词作为标题获取水平数据功能。我知道一个必须是静态的,而另一个则不能是静态的,我只是问我如何将传递给该活动的变量放在cardview中,因为这实际上是我要尝试的操作。
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
protected void onResume() {
super.onResume();
//DETERMINE WHO STARTED THIS ACTIVITY
final String sender = Objects.requireNonNull(this.getIntent().getExtras()).getString("SENDER_KEY");
//IF ITS THE FRAGMENT THEN RECEIVE DATA
if(sender != null)
{
this.receiveData();
Toast.makeText(this, "Received", Toast.LENGTH_SHORT).show();
}
}
public void receiveData() {
//RECEIVE DATA VIA INTENT
Intent i = getIntent();
String word = i.getStringExtra("NAME_KEY");
//SET DATA TO TEXTVIEWS
tv.setText(word);
}
private ArrayList<Object> getObject() {
objects.add(getHorizontalData().get(0));
objects.add(getVerticalData().get(0));
return objects;
}
public static ArrayList<SingleHorizontal> getHorizontalData() {
ArrayList<SingleHorizontal> singleHorizontals = new ArrayList<>();
//String word = "yo";
singleHorizontals.add(new SingleHorizontal(R.mipmap.ic_launcher, "I want word to be right here", "Sir Charles Spencer \"Charlie\" Chaplin, KBE was an English comic actor,....", "2010/2/1"));
singleHorizontals.add(new SingleHorizontal(R.mipmap.ic_launcher, "Mr.Bean", "Mr. Bean is a British sitcom created by Rowan Atkinson and Richard Curtis, and starring Atkinson as the title character.", "2010/2/1"));
singleHorizontals.add(new SingleHorizontal(R.mipmap.ic_launcher, "Jim Carrey", "James Eugene \"Jim\" Carrey is a Canadian-American actor, comedian, impressionist, screenwriter...", "2010/2/1"));
return singleHorizontals;
}
public static ArrayList<SingleVertical> getVerticalData() {
ArrayList<SingleVertical> singleVerticals = new ArrayList<>();
singleVerticals.add(new SingleVertical("Charlie Chaplin", "Sir Charles Spencer \"Charlie\" Chaplin, KBE was an English comic actor,....", R.mipmap.ic_launcher));
singleVerticals.add(new SingleVertical("Mr.Bean", "Mr. Bean is a British sitcom created by Rowan Atkinson and Richard Curtis, and starring Atkinson as the title character.", R.mipmap.ic_launcher));
singleVerticals.add(new SingleVertical("Jim Carrey", "James Eugene \"Jim\" Carrey is a Canadian-American actor, comedian, impressionist, screenwriter...", R.mipmap.ic_launcher));
singleVerticals.add(new SingleVertical("Jim Carrey", "James Eugene \"Jim\" Carrey is a Canadian-American actor, comedian, impressionist, screenwriter...", R.mipmap.ic_launcher));
singleVerticals.add(new SingleVertical("anotha one", "James Eugene \"Jim\" Carrey is a Canadian-American actor, comedian, impressionist, screenwriter...", R.mipmap.ic_launcher));
return singleVerticals;
}
我将数据从片段传递到此活动。如果有人想要Verticaladapter代码或singlevertical类,只需答复。