2013-07-11 25 views
0

我想達到的目的是讓用戶長時間點擊圖庫視圖中的圖像將它們帶到網站。longClickable上的圖庫項目

我有什麼到目前爲止,這是但似乎無法去解決問題....

收到此錯誤

The method setOnLongClickListener(View.OnLongClickListener) in the type View is not applicable for the arguments 
(Integer) 

任何幫助將不勝感激!

回答

0

錯誤告訴你到底發生了什麼問題。 imageIDs [position]返回一個int,而setOnLongClickListener接受一個OnLongClickListener。

imageView.setOnLongClickListener(new OnLongClickListener() { 
    @Override 
    public boolean onLongClick(View v) { 
     Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse ("http://www.google.com")); 
     startActivity(intent); 
     return true; 
    } 
}); 

注:喜歡的東西交換OnItemLongClickListener到OnLongClickListener

+0

感謝您的答覆仍然沒有運氣,雖然,仍然給我同樣的錯誤。 – Allrounder

+0

我想我可以嘗試做的是在網站上的地址,但掩蓋它,即。當用戶點擊文本中的「example」時,它會將它們帶到http://www.google.com。換言之,隱藏uri並僅顯示「示例」。問題是要做到這一點? – Allrounder

+0

@Keithk我改變了我的答案,使用OnLongClickListener而不是OnItemLongClickListener。已經複製了錯誤的代碼。試試看看它是否有效 – Cameron