制作按钮在图像视图上出现和消失
答
好在目前我工作的同样的事情,这里是我的代码进行修改以满足您的需求
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
能你展示你有什么尝试,但我的意思是你的代码? – ingsaurabh 2011-03-17 06:52:00
我还没有尝试过任何东西。只是想要一些指示这样做。 – pradeep 2011-03-17 06:53:27