我有一个listView,它使用我自己创建的适配器。当按下listView的第一行时,我已经创建了它,因此它从名为Ship的类创建了一个具有3个整数值的新对象。以下
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.hangar);
ListAdapter adapter = new HangarAdapter(this, ship);
hangarList.setAdapter(adapter);
hangarList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
Intent sendListEvents = new Intent();
if(position == 0)
{
Ship ship1 = new Ship();
ship1.setAddAmount(50);
ship1.setAddTime(5000);
ship1.setAddSpend(1000);
ship1.shipAdd();
}
}
}
在我的适配器中,我有一个名为TextView2的textView,我想将它的文本设置为ship1的名为addSpend的值。我该怎么做。
if (position == 0) {
theImageView.setImageResource(R.drawable.planet);
TextView2.setText("This is where I want ship1's addSpend value to be displayed")
}