1
DB에 질의 결과를리스트 뷰에 표시해야합니다. 쿼리 2 값 ("cod", "value")을 반환합니다. SimpleAdapter를 사용하여 문제를 해결할 생각 이었지만 작동하지 않았습니다.하위 항목이있는 ListView입니다. (안드로이드)
는 ("대구는", "값")은 HashMap의 값을 포함하는 동일한 코드 utlizando되는 계정에public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.techcharacteristic);
PopulateTechCharacteristicList populateList = new PopulateTechCharacteristicList(
this);
populateList.execute();
SimpleAdapter adapter = new SimpleAdapter(this, list,
R.layout.techcharacteristic_rows,
new String[] {"cod", "value"}, new int[] {
R.id.techCharacteristic, R.id.techCharacteristicName });
setListAdapter(adapter);
}
public class PopulateTechCharacteristicList extends
AsyncTask<Integer, String, Integer> {
ProgressDialog progress;
Context context;
public PopulateTechCharacteristicList(Context context) {
this.context = context;
}
protected void onPreExecute() {
progress = ProgressDialog.show(TechCharacteristicList.this,
getResources().getString(R.string.Wait), getResources()
.getString(R.string.LoadingOperations));
}
protected Integer doInBackground(Integer... paramss) {
ArrayList<TechCharacteristic> arrayTechChar = new ArrayList<TechCharacteristic>();
TechCharacteristicWSQueries techCharWSQueries = new TechCharacteristicWSQueries();
try {
arrayTechChar = techCharWSQueries
.selectTechCharacteristicByAsset("ARCH-0026");
HashMap<String, String> temp = new HashMap<String,
for(TechCharacteristic strAux : arrayTechChar)
{
temp.put("cod", strAux.getTechCharacteristic() + " - " + strAux.getTechCharacteristicName());
temp.put("value", strAux.getTechCharacteristicValue());
list.add(temp);
}
} catch (QueryException e) {
e.printStackTrace();
return 0;
}
return 1;
}
protected void onPostExecute(Integer result) {
if(result == 1)
progress.dismiss();
}
}
, 내 목록보기는 항상 마지막 항목을 보여주고있다 :
이
내 코드입니다 삽입. 그러나 하드 코드 된 ("cod", "value")를 사용하는 내 진술 SimpleAdapter에서 및 ("cod", "value"이외의 다른 값을 HashMap에 둘 때마다 listView는 비어 있습니다.아무도 도와 줄 수 있습니까? 에 동일한 코드 ("대구", "값") utlizando되는 계정에
을 시도하고 같은지도를 사용하지 목적. – Luksprog
postexecute() 메소드에서 어댑터 및 setListAdapter를 초기화 하시겠습니까? – SKT
해결됨, thx 얘들 아! – user1792343