次のコードをフラグメントに実装しようとしました。確かに、構文やその他のエラーを避けるために必要な変更を加えました。提案なしのフラグメントのAutoCompleteTextView
public class MainActivity extends ActionBarActivity {
private AutoCompleteTextView autoCompleteTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
autoCompleteTextView = (AutoCompleteTextView)findViewById(R.id.autoCompleteTextView);
String[]dataStorage = {"Nigeria", "Ghana", "Mali", "South Africa", "Cameroon", "Niger", "Algeria", "Zimbabwe"};
ArrayAdapter adapter = new ArrayAdapter(getApplicationContext(), android.R.layout.select_dialog_item, dataStorage);
autoCompleteTextView.setThreshold(2);
autoCompleteTextView.setAdapter(adapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
エラーなしで実行されていますが、最初の文字の後に検索候補が表示されません。まず、オンスクリーンキーボードは、サブビューと呼ばれるボタンでフルビューモードで開きます。私は何か提案を得ることができないか、多分私はそれを見ることができないので、このフルスクリーンのキーボード。
を私が追加この行はxmlになりましたが、何も変更されませんでした。 – appkovacs
いくつかの文字を入力したときにあなたのアプリのスクリーンショットと、activity_main.xml全体を投稿できますか? – weibeld
これは、以下のように 'TableRow'にあります。アプリケーション画面は本当にシンプルに見えます。 ' AutoCompleteTextView> –
appkovacs