我是新的android.I不理解如何添加與相應的選定圖像更改按鈕的textview。任何人都可以幫助我通過正確的code.How可以做到這一點嗎? 任何幫助是高度讚賞。textview與按鈕在畫廊
-3
A
回答
0
取消您的迴應,設置一個集合或一個數組列表來保存您的對象,然後根據您點擊的內容來引用它們。
如果圖像是活動中唯一的對象,以下是如何使用單個圖像執行此操作的方法。
XML:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/image"
android:src="@drawable/YOUR_IMAGE_RESOURCE"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text for the picture"
android:visibility="invisible"
android:id="@+id/text"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:id="@+id/button"
android:visibility="invisible"
/>
</LinearLayout>
的Java
ImageView photoImage = (ImageView)findViewById(R.id.image);
TextView text = (TextView)findViewById(R.id.text);
Button button = (Button)findViewById(R.id.button);
photoImage.setOnClickListener(new OnClickListener{
void onClick(View v){
text.setVisibility(View.VISIBLE);
button.setVisibility(View.VISIBLE);
}
});
// Set the OnClickListener for "button" here, to start a new intent or whatever
如果您正在使用多個按鈕,設置一個ArrayList或集合像我上面所述。
[編輯]
你的代碼,把東西放到一個數組列表如下所示...
List<TextView> tvs = new ArrayList<TextView>();
// Setup the views
for (int i = 0; i < numberOfTextViews; i++){
TextView thisTextView = new TextView(context);
// Setup whatever layout info you want here
tvs.add(thisTextView);
}
// Use a view inflater here to add each of the textviews however you want (table layout, linearlayout, etc.)
基礎上,無論你想,你可以再做...只是使用tvs.get(NUMBER)
來攔截你正在尋找的任何東西。您可以使用按鈕或其他任何方式執行相同的操作,並使用相同的NUMBER同時參考字符串,文本瀏覽和按鈕。例如,點擊按鈕編號1 ...您可以使用tvs.get(1)
,buttons.get(1)
,stringResources.get(1)
這樣做更有意義嗎?
+0
我更新了我的代碼 – RyanInBinary 2012-09-04 14:49:23
相關問題
- 1. 滾動畫廊的按鈕
- 2. Featherlight.JS:畫廊是否有按鈕
- 3. 停用畫廊滑塊上的按鈕
- 4. 畫廊滾動時點擊按鈕?
- 5. 停用畫廊滑塊上的按鈕
- 6. blueimp畫廊將在圖像刪除按鈕始終打開畫廊
- 7. 幫助加載「畫廊」畫廊與.load
- 8. facebook喜歡按鈕動態縮略圖與ajax畫廊
- 9. 與畫廊活動
- 10. 彩盒與畫廊
- 11. Django畫廊與jquery
- 12. 的ListView與畫廊
- 13. 我在js中的畫廊按鈕將不起作用
- 14. 在Powerapps中,如何使用單選按鈕過濾畫廊?
- 15. 在畫廊
- 16. Fancybox畫廊與jQuery的.live()
- 17. Phoca畫廊:錯誤與畫廊中的Facebook相冊的集成
- 18. 與兩個TextView的自定義按鈕
- 19. 按鈕重疊textview
- 20. 更改/刪除羽毛畫廊的next/prev按鈕
- 21. Fancybox沒有導航按鈕,但畫廊作品
- 22. 你如何從一個按鈕打開一個畫廊?
- 23. ScrollView裏面的按鈕裏面的畫廊不響應點擊
- 24. Android畫廊意圖(startActivityForResult)後退按鈕錯誤
- 25. 如何解決js畫廊中的下一個按鈕
- 26. jQuery畫廊翻過下一個和上一個按鈕
- 27. 在IE7和IE8的拱廊Javascript畫廊
- 28. 動態創建按鈕textview按鈕
- 29. Android畫廊
- 30. 內置畫廊
用按鈕添加textview?那是什麼意思?請讓你的要求更清楚些,以便我們解決你的問題。 – RyanInBinary 2012-08-17 17:43:23