私のレイアウトでは、いくつかの選択を行ういくつかのボタンと、データベースへのクエリを実行するための 1 つのボタンがあります。このクエリの結果は、ListView
このレイアウト内に表示されます。
問題は、クエリを実行した後に画面を回転させると、がListView
消えてクエリを再度実行する必要があることです。
これは、活動が再開したからだと思います。ここでの提案に従って、マニフェストのアクティビティと追加されandroid:configChanges="orientation|keyboardHidden"
たコードに追加しました。
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
setContentView(R.layout.mylayout);
}
しかし、これは機能していません。
私の活動の完全なコードは次のとおりです。
public class MyClass extends ListActivity implements OnClickListener, OnCheckedChangeListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.mylayout);
// Creates the buttons and setOnClickListener and setOnCheckedChangeListener
}
@Override
public void onClick(View v) {
// Manages the buttons and their functions
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// See what group in radio group is checked
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// After pressing one button, a query is made and a listview is shown.
// This it to handle the user choice after he clicks an item on the listview
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
setContentView(R.layout.mylayout);
}
}
私はこのような他の活動をしているので、これは奇妙です:
public class AtoZ extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.atoz);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
}
}
これはまた、データベースへのクエリを実行し、それを に表示してからListView
、ユーザーの選択を処理します。画面を回転させてListView
も表示されます。
私に何ができる?