我想在此类表格中显示来自string.xml
的{{1}}的一些数据
以下是我要找的表格图片:
我必须string-array
,但我不知道如何
以下是我的自定义custom adapter
listview
怎么做?谢谢
答案 0 :(得分:0)
Listview适配器:
public class TalktimeAdapter extends ArrayAdapter<PlanDetails> {
Context context;
View view;
public TalktimeAdapter(Context context,List<PlanDetails> items) {
super(context,0, items);
this.context=context;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
PlanDetails rowitem= getItem(position);
view=convertView;
ViewHolder holder;
if (view==null){
LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view=inflater.inflate(R.layout.fulltalk_items,parent,false);
holder=new ViewHolder();
holder.planoverview=(TextView)view.findViewById(R.id.planoverview);
holder.planbenefit=(TextView)view.findViewById(R.id.planbenefit);
holder.planamount=(TextView)view.findViewById(R.id.planamount);
view.setTag(holder);
}else{
holder=(ViewHolder)view.getTag();
}
assert rowitem != null;
holder.planoverview.setText(rowitem.getOne());
holder.planbenefit.setText(rowitem.getTwo());
holder.planamount.setText(rowitem.getThree());
return view;
}
private static class ViewHolder
{
TextView planoverview,planbenefit,planamount;
}
}
模特课:
public class PlanDetails {
String one,two,three;
public PlanDetails(String one, String two, String three) {
this.one = one;
this.two = two;
this.three = three;
}
public String getThree() {
return three;
}
public void setThree(String three) {
this.three = three;
}
public String getTwo() {
return two;
}
public void setTwo(String two) {
this.two = two;
}
public String getOne() {
return one;
}
public void setOne(String one) {
this.one = one;
}
}
的活动:
public class FullTalkTimeActivity extends AppCompatActivity {
ListView listView;
TalktimeAdapter adapter;
List<PlanDetails> row;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fulltalk_view);
listView=(ListView)findViewById(R.id.planList);
row = new ArrayList<>();
row.add(new PlanDetails("oneoneone","twotwotwo","11"));
row.add(new PlanDetails("oneoneone","twotwotwo","12"));
row.add(new PlanDetails("oneoneone","twotwotwo","13"));
row.add(new PlanDetails("oneoneone","twotwotwo","14"));
row.add(new PlanDetails("oneoneone","twotwotwo","15"));
row.add(new PlanDetails("oneoneone","twotwotwo","16"));
row.add(new PlanDetails("oneoneone","twotwotwo","17"));
row.add(new PlanDetails("oneoneone","twotwotwo","18"));
row.add(new PlanDetails("oneoneone","twotwotwo","19"));
row.add(new PlanDetails("oneoneone","twotwotwo","21"));
row.add(new PlanDetails("oneoneone","twotwotwo","31"));
row.add(new PlanDetails("oneoneone","twotwotwo","41"));
row.add(new PlanDetails("oneoneone","twotwotwo","51"));
row.add(new PlanDetails("oneoneone","twotwotwo","61"));
row.add(new PlanDetails("oneoneone","twotwotwo","71"));
row.add(new PlanDetails("oneoneone","twotwotwo","81"));
row.add(new PlanDetails("oneoneone","twotwotwo","91"));
row.add(new PlanDetails("oneoneone","twotwotwo","101"));
row.add(new PlanDetails("oneoneone","twotwotwo","121"));
row.add(new PlanDetails("oneoneone","twotwotwo","1011"));
row.add(new PlanDetails("oneoneone","twotwotwo","1521"));
row.add(new PlanDetails("oneoneone","twotwotwo","1081"));
row.add(new PlanDetails("oneoneone","twotwotwo","1291"));
row.add(new PlanDetails("oneoneone","twotwotwo","1001"));
row.add(new PlanDetails("oneoneone","twotwotwo","1261"));
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
PlanDetails pm= row.get(i);
Toast.makeText(FullTalkTimeActivity.this,pm.getThree().trim(),Toast.LENGTH_SHORT).show();
}
});
adapter = new TalktimeAdapter(getActivity(), row);
listView.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
}