0
我正在使用this教程。我有一個單選按鈕的listview。當我點擊listview值所有單選按鈕改變checked.i當我單擊提交按鈕時希望單選模式和選中單選按鈕列表值。 這是我onpostexecuteListView與服務器的單選按鈕
protected void onPostExecute(JSONObject file_url) {
// dismiss the dialog after getting all albums
Log.d("Arraylist: ", "> " + AddressList);
pDialog.dismiss();
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
/**
* Updating parsed JSON data into ListView
* */
if(!AddressList.isEmpty())
{
final ListAdapter adapterlist = new SimpleAdapter(
PlaceEnquiryActivity.this, AddressList,
R.layout.addressscreenlist, new String[] { ADDRESS,
CITY, STATE, COUNTRY }, new int[] {R.id.address,
R.id.city, R.id.state, R.id.country});
// updating listview
setListAdapter(adapterlist);
這是在活動列表視圖的onclick功能
final ListView lv = getListView();
lv.setItemsCanFocus(false);
lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View v, int arg2, long arg3) {
RadioButton rb = (RadioButton) v.findViewById(R.id.rb_Choice);
if (!rb.isChecked()) //OFF->ON
{
for (HashMap<String, String> m:AddressList) //clean previous selected
rb.setChecked(true);
//lv.getAdapter().notifyDatasetChanged();
}
}
});