webserviceからの値を含むlistviewがあります。各ページには10個のlistitemと次の10個のページがあります。各listitemはクリック可能で、主に投票用のボタンが含まれています。リスト項目1のボタンをクリックすると、Webサービスに値が追加されます。androidのリストビューをリフレッシュする
ボタンのクリックコードは、カスタムベースアダプタクラスに配置されています。私は簡単にvote.Butを追加することができますので、私は投票を提出すると、私もリストビューを更新したいです。いいえ、リストビューのページをリフレッシュしてください。
webserviceに値を送信した後、このリストビューを直ちに更新できますか? main.java
private class ProgressThreadNextPageLoading extends
AsyncTask<String, Void, String> {
// private String Content;
@Override
protected void onPreExecute() {
progressDialog = new ProgressDialog(KidsCrackMeUp.this);
progressDialog.setMessage("Loading..Please Wait..");
progressDialog.setIcon(R.drawable.icon);
progressDialog.show();
}
@Override
protected String doInBackground(String... urls) {
String response = "";
// call ur webservice here
try {
// pagenum = 1;
posts= web
.getAllposts(pagenum);
response = "Yes";
} catch (Exception e) {
e.printStackTrace();
response = "Failure";
}
return response;
}
@Override
protected void onPostExecute(String result) {
// below line code is to dismiss the progress bar
progressDialog.dismiss();
if (posts != null) {
adapter = new DynamicListAdapter(
main.this, posts
lstPosts.setAdapter(adapter);
adapter.notifyDataSetChanged();
//btnState.setPressed(true);
}
ため
サンプルコード--------------------------------- -customアダプタクラス
viewHolder.btnVoting.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
final Dialog d = new Dialog(activity);
d.requestWindowFeature(Window.FEATURE_NO_TITLE);
d.setContentView(R.layout.voteselectornew);
Button btnCategoryCancel = (Button) d
.findViewById(R.id.btnCategoryCancel);
Button twcVote = (Button) d
.findViewById(R.id.btnTwcVote);
twcVote.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
String confirm = web
.addTwcVote(UserSessionKey, Userlist.get(position).contentid);
if (confirm.contains("Successfully")) {
d.dismiss();
}
[Androidリストビューの更新](http://stackoverflow.com/questions/4088862/android-list-view-refresh)の複製が可能 –