2つの活動をしています
最初のものは、コンテンツ プロバイダーからデータを取得して表示します。
2 番目のアクティビティにはボタンがあり、クリックすると、最初のアクティビティを呼び出して「更新」する必要があります。つまり、コンテンツ プロバイダーからデータをリロードします。
初めての活動です
...
@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();
}
...
そして、これは私の2番目の活動です
@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);
}
これは、そのような機能を実装する正しい方法ですか? 間違っているように感じますが、主張を裏付ける理由がわかりません