2017-10-11 23 views
2

Home.activityに単純なドロップダウンを持つがありますが、これはうまくいきますが、私のアプリはほとんど公開準備が整っています。 1。
AutoCompleteTextViewのドロップダウンには8つの都市名が含まれていますが、それは見た目は素晴らしいですが、最初にAutoCompleteTextviewをクリックすると、キーボードがポップアップして再びクリックするとドロップダウンが表示されます。
キーボードを使用した最初のクリックでこのドロップダウンが表示されます。

これは私の実装のコードです。ドロップダウンが2回目のクリックで表示される - AutoCompleteTextView with dropdown

<AutoCompleteTextView 
     android:layout_width="200dp" 
     android:layout_height="30dp" 
     android:hint="@string/select_city" 
     android:id="@+id/acT1" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     android:background="@drawable/shape1" 
     android:textAlignment="center" 
     app:layout_constraintVertical_bias="0.25" 
     android:dropDownHeight="155dp" 
     android:cursorVisible="false" 
     android:maxLines="1"/> 

final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(
       this, android.R.layout.simple_list_item_1, getResources() 
       .getStringArray(R.array.Loc_names)); 
     textView1 = findViewById(R.id.acT1); 
     textView1.setAdapter(arrayAdapter); 
     textView1.setThreshold(1); 
     textView1.setCursorVisible(false); 
     textView1.setOnItemClickListener(new AdapterView.OnItemClickListener() { 

      @Override 
      public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 
       textView1.showDropDown(); 
       textView1.setCursorVisible(false); 
       hideKeyBoard(view); 
       selection = (String) parent.getItemAtPosition(position); 
       TastyToast.makeText(getApplicationContext(), selection, 
       TastyToast.LENGTH_LONG, TastyToast.SUCCESS); 
       imageView.setAlpha(.8f); 
      } 


     }); 
     textView1.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(final View arg0) { 
       textView1.showDropDown(); 
       textView1.setCursorVisible(true); 
       //imageView.setAlpha(.8f); 
      } 
     }); 

Here's the GIF

+0

スクリーンショットでみては? – PrakhaRaM

+0

@PrakhaRam [こちらはGIFです](https://giphy.com/gifs/3ohhwDnMGpg3lV8j16) –

+0

何をダブルクリックしてリストを開くのではなく、autocompletetextviewによってこれをフィーチャーとして取って、入力されたクエリーのフィルター結果をドロップダウンに表示します。 – PrakhaRaM

答えて

0

だけAutoCompleteTextView

+0

これは、キーボードを永久に無効にします。 –

+0

これを試してみてください Manivash

0

にFALSEとOnclickable TRUEフォーカスを追加するには、あなたのドロップダウンが見ているかのontouchリスナー

textview1.setOnTouchListener(new OnTouchListener() { 
    @Override 
    public boolean onTouch(View v, MotionEvent event) { 
     // TODO Auto-generated method stub 

     if(event.getAction() == MotionEvent.ACTION_UP){ 
      touching = false; 
     }else if(event.getAction() == MotionEvent.ACTION_DOWN){ 
      touching = true; 
      handle event 
     } 
     return true; 
    } 
関連する問題