2015-05-23 3 views
2

Я После компоновки сценарияНажмите Событие View Внутри Framelayout

enter image description here

Хотите реализовать Нажмите даже TextView ..но TextView Нажмите не работает

Вот Пример кода

<FrameLayout 
     android:id="@+id/frame" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_centerInParent="true" 
     android:clickable="false"> 

     <customview 
      android:id="@+id/custom" 
      android:layout_width="200dp" 
      android:layout_height="200dp" 
      android:clickable="false"/> 

     <LinearLayout 
      android:id="@+id/abc" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:orientation="vertical" > 

      <TextView 
       android:id="@+id/btn" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/zero_done" 
       android:padding="5dp" 
       android:clickable="true" 
       android:textAppearance="?android:attr/textAppearanceMedium" 
       android:textStyle="bold" /> 



     </LinearLayout> 

My TextView ClickEvent не работает ... пожалуйста, помогите мне

Код класса

TextView view= (TextView) findViewById(R.id.btn); 

     view.setOnClickListener(new OnClickListener() { 

      @Override 
      public void onClick(View v) { 
       // TODO Auto-generated method stub 

       Toast.makeText(getApplicationContext(), "Press", 
         Toast.LENGTH_SHORT).show(); 
      } 
     }); 
+0

Пожалуйста, вы можете показать нам код, где вы назначаете onClickListener? –

+0

@BojanKseneman проверить обновление –

+0

Можете ли вы попытаться изменить его id на что-то еще, может быть, у вас есть другое представление с этим id. Используйте что-то вроде tvBtn123 –

ответ

0

Вы не звонок метод Toast, так что вы понятия не имеете ли TextView нажмите событие случилось или нет.

Попробуйте это:

Toast.makeText(getApplicationContext(), "Press", 
        Toast.LENGTH_SHORT).show(); // don't miss show method. 
Смежные вопросы