我从webservice获取一些细节,我需要动态显示这些细节与左侧相关的复选框(使用java代码)。我已经正确地将所有细节映射到Hashmap Arraylist,接下来该做什么就是显示警报箱的所有细节,在我的代码中定义。我尝试了很多。任何人都可以帮助我任何帮助都会非常值得.......
selectButton.setOnClickListener(new View.OnClickListener() {
private Builder mDialog;
@Override
public void onClick(View v) {
Log.e(tag,"alertbox for onclickworked");
Context c =getParent();
this.mDialog = new AlertDialog.Builder(c);
alertDialog = mDialog.create();
// Setting Dialog Title
alertDialog.setTitle("Intrested In");
new Serviceclass().execute();
// Setting Icon to Dialog
alertDialog.setIcon(R.drawable.gate_logo);
alertDialog.show();
}
class Serviceclass extends AsyncTask<Void, Void, String>
{
protected String doInBackground(
Void... params) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
Log.e(tag,"inside getvaluesforcheckbox()");
offferList = new ArrayList<HashMap<String, String>>();
Log.e(tag,"arraylist created");
try{
UserFunctions usf=new UserFunctions();
JSONObject json2 = usf.intrestlist(user_id);
Log.e(tag,"before try");
Log.e(tag,"after try");
JSONArray contacts = json2.getJSONArray("interested_list");
Log.e(tag,"outside forloop");
for(int i = 0; i < contacts.length(); i++){
Log.e(tag,"inside forloop");
HashMap<String, String> map = new HashMap<String, String>();
JSONObject c = contacts.getJSONObject(i);
map.put(KEY_INTRESTID, c.getString("interested_id"));
Log.e("requestclass.java",c.getString("interested_id"));
map.put(KEY_INTRESTNAME, c.getString("interested_name"));
Log.e("requestclass.java",c.getString("interested_name"));
map.put(KEY_STAUS, c.getString("status"));
Log.e("requestclass.java",c.getString("status"));
if(c.getString("interested_info").equals("null"))
{
map.put(KEY_INTERESTINFO,"");
}
else
{
map.put(KEY_INTERESTINFO,c.getString("interested_info"));
}
offferList.add(map);
// cadapter = new ClientListAdapter(this, R.layout.client_list,
// ClientDetailsCollection.getClientDetailssAsArray(), this);
}
Log.e(tag,"datas added to arraylist");
checkboxgeneration();
}
catch(Exception e)
{
e.printStackTrace();
}
return null;
}
protected void onPostExecute() {
HERE I NEED TO WRITE THE CODE
}
}
提前谢谢.....
答案 0 :(得分:0)
您有Web请求,可以在对话框中显示和显示记录。在这里我建议你。
1.使用DialogFragments.
2.内部片段制作一个列表视图,根据您的设计创建自定义适配器。
3.在片段内部创建Web请求。
4。为方便起见,您可以阅读本教程Android DialogFragment and ListView