2015-12-24 122 views
0

一段代碼我創建打開圖像需要我點擊兩次上的文字來打開圖像。我不明白爲什麼它不響應只是一個點擊。需要兩個CLICS而不是一個

在這裏的佈局是TextView的

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:text="The New Yorker" 
    android:id="@+id/the_new_yorker" 
    android:textStyle="italic" 
    android:textColor="@color/blue" 
    android:onClick="new_yorker_cartoon"/> 

,這裏是在java文件中的相應的功能

public void new_yorker_cartoon(View view) { 
    final TextView TextGenerique = (TextView) findViewById(R.id.the_new_yorker); 
    View.OnClickListener monEcouteur = new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      String imageUrl = "http://www.lapasserelle.com/english/l09/imgs/new_yorker.gif"; 
      Intent intent = new Intent(Intent.ACTION_VIEW); 
      intent.setDataAndType(Uri.parse(imageUrl), "image/gif"); 
      startActivity(intent); 
      } 
     }; 
    TextGenerique.setOnClickListener(monEcouteur); 
} 

我不明白的是爲什麼我需要在點擊兩次詞紐約人在我的手機上顯示圖像new_yorker.gif。

+0

嘗試把日誌語句在你的onClick()方法,看看當你點擊,一旦他們出現。 –

回答

0

這可能是第一次點擊是激活屏幕和第二獲得響應。

相關問題