我有一個圖像視圖,我想創建兩個按鈕,使用戶能夠轉到下一個或上一個圖像。當用戶點擊圖像時,按鈕應該出現,在第二次點擊時,按鈕應該消失。如何去做這件事?製作按鈕在圖像視圖上出現和消失
1
A
回答
6
好在目前我工作的同樣的事情,這裏是我的代碼進行修改以滿足您的需求
XML代碼
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/image"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<LinearLayout
android:id="@+id/button_holder"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:visibility="gone">
<Button
android:id="@+id/buy"
android:text="Buy"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:id="@+id/cancel"
android:text="Cancel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</RelativeLayout>
主代碼
Button mBuy = (Button) findViewById(R.id.buy);
mBuy.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
}
});
Button mCancel = (Button) findViewById(R.id.cancel);
mCancel.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
finish();
}
});
ImageView mView = (ImageView) findViewById(R.id.image);
mView.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
LinearLayout mLayout = (LinearLayout) findViewById(R.id.button_holder);
if(!isVisible)
{
isVisible = true;
mLayout.setVisibility(View.VISIBLE);
}
else
{
isVisible = false;
mLayout.setVisibility(View.GONE);
}
}
});
+0
非常感謝。 U just rock – pradeep 2011-03-17 10:18:06
+0
歡迎,如果您的查詢已解決,您可以正確標記答案,以便其他人會認爲它有用 – ingsaurabh 2011-03-17 10:44:06
+0
我做到了。隨着投票 – pradeep 2011-03-17 10:54:21
相關問題
- 1. 製作按鈕出現和消失
- 2. 使圖像出現和其他圖像隨着點擊一個按鈕消失
- 3. 按鈕與圖像 - 圖像消失
- 4. 導致圖像出現/消失在按鈕點擊
- 5. 圖像視圖和按鈕沒有出現在模擬器
- 6. 按鈕與圖像,圖像消失點擊按鈕時iOS 10
- 7. 使圖像視圖不再出現在視圖控制器上
- 8. 在按鈕按下後出現圖像
- 9. 在視圖上自動完成按鈕touchupinside動作出現?
- 10. 製作按鈕出現,然後在Android幾秒鐘後消失
- 11. 按鈕上的背景圖像消失在鼠標上
- 12. 圖像(位圖)在繪製在表面視圖上的畫布上消失
- 13. 按鈕不出現在滾動視圖
- 14. cck圖像在製作node_save時消失
- 15. 選項卡和圖像視圖按鈕
- 16. 按鈕中的圖像視圖不會出現
- 17. 圖像存在時隱藏上傳按鈕,當圖像消失時顯示?
- 18. 圖像在列表視圖中消失
- 19. 按鈕位圖消失
- 20. 按鈕操作無法在視圖上的按鈕上工作
- 21. 當鼠標懸停在圖像上時,像按鈕出現
- 22. 新的視圖控制器出現,然後消失在CCScene
- 23. 試圖在codeigniter中製作像按鈕
- 24. 修改圖像視圖按鈕上點擊按鈕動態
- 25. 從控制器的視圖MVC更改圖像按鈕圖像
- 26. DataGrid視圖按鈕列出現問題
- 27. iPhone:動畫視圖另一個視圖時出現/消失
- 28. iOS鍵盤製作視圖消失
- 29. iOS ::導航欄上的按鈕僅出現在根視圖控制器上
- 30. 後退按鈕不會出現在視圖控制器
能你展示你有什麼嘗試,但我的意思是你的代碼? – ingsaurabh 2011-03-17 06:52:00
我還沒有嘗試過任何東西。只是想要一些指示這樣做。 – pradeep 2011-03-17 06:53:27