今天是周四,上午在APP中增加了商品列表的展示,代码如下:
public class BuhuoActivity extends AppCompatActivity implements View.OnClickListener {标签:总结,map,0420,intent,private,new,今日,id,View From: https://www.cnblogs.com/zbw-m/p/17344277.html
private ListView mSimpleList;
private SimpleAdapter mSimpleAdapter;
private List<Map<String, Object>> mList;
private int[] imgs = {
R.drawable.img,
R.drawable.img1,
R.drawable.img2,
R.drawable.img3,
};
int number = new Random().nextInt(10) + 1;
String[] eqs = {"是", "否"};
public String eqq(int t) {
t = number;
if (t <= 4) {
return eqs[0];
} else {
return eqs[1];
}
}
private Button btnmap, btntoadd;
@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_buhuo);
btnmap = findViewById(R.id.btn_map);
btntoadd = findViewById(R.id.btn_ToAdd);
btnmap.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(BuhuoActivity.this, MapActivity.class);
startActivity(intent);
}
});
btntoadd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(BuhuoActivity.this, ShenqingActivity.class);
startActivity(intent);
}
});
mSimpleList = findViewById(R.id.lv1);
mList = new ArrayList<>();
for (int i = 1; i < 12; i++) {
Map<String, Object> map = new HashMap();
map.put("img", imgs[i % imgs.length]);
map.put("title", "商品" + i);
map.put("content1", "当前剩余:" + number);
map.put("content2", "是否需要补货:" + eqq(number));
mList.add(map);
}
mSimpleAdapter = new SimpleAdapter(this,
mList,
R.layout.list_item_layout,
new String[]{"img", "title", "content1", "content2"},
new int[]{R.id.iv_img, R.id.tv_title, R.id.tv_content1, R.id.tv_content2}
);
mSimpleList.setAdapter(mSimpleAdapter);
}
遇到的问题:本来想写一个柱状图,但是导入的接口文件中的一个方法参数只有可读权限,没办法依照此项目进行修改。
明天要干什么:在原本的地图接口上接入导航接口。