在我的应用程序中有两个活动A和B,B活动作为对话框活动。当在活动A中它显示对话框活动B时,我在活动B中有按钮,当我单击按钮时,它将刷新列表视图活动艾不知道怎么做这件事。任何人都知道请帮我解决这个问题。
活动A
Intent i = new Intent();
i.setClass(Activity_A.this, Activity_b.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
活动b
public class Activity_b extends Activity{
Button yes;
@SuppressLint({ "NewApi", "NewApi", "NewApi" })
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setBackgroundDrawable(new ColorDrawable(0));
setContentView(R.layout.dialog_timeout);
this.rootView=findViewById(R.id.dialog1);
yes = (Button)findViewById(R.id.dialog_yes);
yes.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
finish();
}
});
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
/*Intent i = new Intent(Wheel_order.this,MainActivity.class);
startActivity(i);
finish();*/
}
return true;
}
答案 0 :(得分:0)
使用startActivityForResult
方法http://developer.android.com/reference/android/app/Activity.html#StartingActivities