Android 单击图像按钮打开滑块
我有一些问题 这是我的android版本现在的页脚栏,当我想,当我点击我的按钮,然后滑块栏应该与其他按钮打开,如 我如何在安卓系统中做到这一点 我尝试了一些使用警报对话框的工作,但它不起作用 有人知道我该怎么做吗Android 单击图像按钮打开滑块,android,slider,Android,Slider,我有一些问题 这是我的android版本现在的页脚栏,当我想,当我点击我的按钮,然后滑块栏应该与其他按钮打开,如 我如何在安卓系统中做到这一点 我尝试了一些使用警报对话框的工作,但它不起作用 有人知道我该怎么做吗 如果有任何帮助,我们将不胜感激。这样做的一种方法是使用包含要显示或隐藏的按钮行的布局。然后可以使用OnClickListener设置按钮单击以显示或隐藏布局。因此,类似这样的活动可能会奏效: @Override public void onCreate(Bundle savedIn
如果有任何帮助,我们将不胜感激。这样做的一种方法是使用包含要显示或隐藏的按钮行的布局。然后可以使用OnClickListener设置按钮单击以显示或隐藏布局。因此,类似这样的活动可能会奏效:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button toggleButton = (Button)findViewById(R.id.toggle_button);
//Set click listener to change the bar visiblity
toggleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LinearLayout bar = (LinearLayout)findViewById(R.id.toggle_bar);
int visibility = bar.getVisibility();
//Hide or show the bar according to it's current visibility
if (visibility == View.VISIBLE) {
bar.setVisibility(View.GONE);
} else {
bar.setVisibility(View.VISIBLE);
}
}
});
}
简单的示例layout main.xml可能看起来有点像这样:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="50.0dp"
android:orientation="horizontal" >
<Button
android:id="@+id/toggle_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Toggle visibility"
/>
<LinearLayout
android:id="@+id/toggle_bar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Button1"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Button2"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Button2"
/>
</LinearLayout>
</LinearLayout>
如果您还需要在可见性更改时设置按钮行的动画,您可能应该查看。执行类似操作的一种方法是使用包含要显示或隐藏的按钮行的布局。然后可以使用OnClickListener设置按钮单击以显示或隐藏布局。因此,类似这样的活动可能会奏效:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button toggleButton = (Button)findViewById(R.id.toggle_button);
//Set click listener to change the bar visiblity
toggleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LinearLayout bar = (LinearLayout)findViewById(R.id.toggle_bar);
int visibility = bar.getVisibility();
//Hide or show the bar according to it's current visibility
if (visibility == View.VISIBLE) {
bar.setVisibility(View.GONE);
} else {
bar.setVisibility(View.VISIBLE);
}
}
});
}
简单的示例layout main.xml可能看起来有点像这样:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="50.0dp"
android:orientation="horizontal" >
<Button
android:id="@+id/toggle_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Toggle visibility"
/>
<LinearLayout
android:id="@+id/toggle_bar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Button1"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Button2"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Button2"
/>
</LinearLayout>
</LinearLayout>
如果您还需要在可见性更改时设置按钮行的动画,您可能应该查看。您应该首先在anim文件夹中的.xml中放置一张幻灯片:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="100%p" android:toXDelta="0" android:duration="500" />
</set>
您应该首先在动画文件夹中有一张幻灯片\u right\u in.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="100%p" android:toXDelta="0" android:duration="500" />
</set>
嘿,阿南,你能给我一些关于动画的和平代码吗。现在你和CDNyes合作了吗?你说得对,你是怎么做到的?嘿,阿南,你能给我一些动画的代码吗。现在你在和CDNyes合作吗?你说的对,你是怎么得到的?谢谢你,伙计,它的炒锅很好。你帮我节省了很多时间。谢谢你,伙计,它的炒菜很好。你节省了我很多时间。