我有两个活动
第一个从内容提供者那里获取一些数据,并显示它
第二个活动有一个按钮,当点击它应该调用第一个活动“刷新”,换句话说,从内容提供者重新加载数据
这是我的第一个活动
...
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.contactsview);
// Grab data and put it onto screen
getDataAndPutToUI();
}
@Override
public void onStart()
{
//Refresh data
getDataAndPutToUI();
}
...
这是我的第二个活动
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.optionsview);
Button button = (Button) findViewById(R.id.intentButton);
button.setOnClickListener(this);
}
// This is bound to the "refresh" button
@Override
public void onClick(View v) {
// Call first activity, to reload the contacts
Intent i = new Intent(this, FirstActivity.class);
startActivity(i);
}
这是实现此类功能的正确方法吗?感觉不正确,但我无法确定任何理由来支持我的声明