public class ChallengesActivity extends ListActivity {
private SimpleAdapter adapter;
private ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
printTripsToScreen();
setContentView(R.layout.challenge_list);
adapter = new SimpleAdapter(this, list, R.layout.challenge_row,
new String[] {"description","progress"},
new int[] {R.id.ch_description, R.id.ch_progress});
setListAdapter(adapter);
}
public void printTripsToScreen() {
Log.d("Carbon","ChallengesActivity: printTripsToScreen() started");
ChallengeManager chManager = new ChallengeManager();
ArrayList<Challenge> challenges = chManager.getChallenges();
HashMap<String,String> temp;
for (int i=0; i<challenges.size();i++){
temp = new HashMap<String,String>();
temp.put("description","Hello");
temp.put("progress", ""+challenges.get(i).getCompleted_percentage());
list.add(temp);
}
}
}
我需要更新进度条中的值。我正在使用适配器和 HashMap 来更新文本内容。如何更新进度条中的值?如果这不是方法,请让我知道该怎么做?该列表是动态的。