BaseAdapter不更新是怎么回事
这个问题纠结我很久了,那位大虾要是看到了,帮我解决一下,谢谢了问题出在public void onTabActivityResult(int requestCode, int resultCode, Intent data) 这个方法里,在这个方法里调用adapter = new ContactMainAdapter(AddNewActivity.this, list);
listView.setAdapter(adapter);
adapter.notifyDataSetChanged();
这样死活不更新,而不在这个方法里调用addDataSource()这个方法,是可以正常显示数据刷新的,我在里面这样调用这个方法也没用
下面这个是TabHost的那个Activity一段代码
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// 获取当前活动的Activity实例
@SuppressWarnings("deprecation")
Activity subActivity = manager.getCurrentActivity();
//判断是否实现返回值接口
if (subActivity instanceof OnTabActivityResultListener) {
//获取返回值接口实例
OnTabActivityResultListener listener = (OnTabActivityResultListener) subActivity;
//转发请求到子Activity
listener.onTabActivityResult(requestCode, resultCode, data);
}
super.onActivityResult(requestCode, resultCode, data);
}
public inte易做图ce OnTabActivityResultListener {
public void onTabActivityResult(int requestCode, int resultCode, Intent data);
}
package com.vzo.eightpartycall.activity;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.LocalActivityManager;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewStub;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.vzo.eightpartycall.R;
import com.vzo.eightpartycall.activity.MainActivity.OnTabActivityResultListener;
import com.vzo.eightpartycall.adapter.ContactMainAdapter;
import com.vzo.eightpartycall.bean.ContactBean;
public class AddNewActivity extends Activity implements OnClickListener,OnTabActivityResultListener {
private static final String TAG = AddNewActivity.class.getSimpleName();
private TextView tv_minute;
private Button bt_cacel, bt_add, bt_softKey, add_contact;
private ListView listView;
private ImageButton ib_sms, ib_call, ib_collet;
private RelativeLayout relayout;
private LinearLayout llayoutButton;
private LinearLayout topLayout;
private Dialog smsDialog;
private View smsView;
private EditText ed_title, ed_month, ed_day, ed_hour;
private EditText ed_emcee, ed_bafanghao, ed_passWord;
private Button bt_ensure, bt_cancel;
private ViewStub stub;
private List<ContactBean> list = new ArrayList<ContactBean>();
private ContactMainAdapter adapter;
private Handler handler = new Handler(){
public void handleMessage(Message msg) {
switch (msg.what) {
case 1:
addDataSource();
break;
default:
break;
}
};
};
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
Log.i(TAG,"onCreate");
setContentView(R.layout.addnew);
initView();
// addDataSource();
}
private void initView() {
tv_minute = (TextView) findViewById(R.id.avariable_minute);
bt_cacel = (Button) findViewById(R.id.topCancelButton);
bt_cacel.setO
补充:综合编程 , 其他综合 ,