Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 切换到不同布局/活动时显示的动画。按钮栏_Java_Android_Xml_Android Activity_Buttonbar - Fatal编程技术网

Java 切换到不同布局/活动时显示的动画。按钮栏

Java 切换到不同布局/活动时显示的动画。按钮栏,java,android,xml,android-activity,buttonbar,Java,Android,Xml,Android Activity,Buttonbar,在整个布局和活动中,我都使用了按钮栏。当我按下另一个按钮并按下手机上的“后退”按钮时,我会收到一个“交换”动画,并返回到以前的所有活动/布局。。这些按钮工作得很好,我认为这与java中的意图有关。在这种情况下,ViewFlipper是更好的选择吗?或者,是否可以使用意图删除此项。谢谢 buttonbar.xml <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_wid

在整个布局和活动中,我都使用了按钮栏。当我按下另一个按钮并按下手机上的“后退”按钮时,我会收到一个“交换”动画,并返回到以前的所有活动/布局。。这些按钮工作得很好,我认为这与java中的意图有关。在这种情况下,ViewFlipper是更好的选择吗?或者,是否可以使用意图删除此项。谢谢

buttonbar.xml

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" 
android:shrinkColumns="*"  
android:stretchColumns="*" 
android:background="#6B1414">
<TableRow
    android:id="@+id/tableRow1"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent">
    <Button
        android:id="@+id/btn1"
        android:text="@string/Str"
        android:textStyle="bold"
        android:layout_width="0dip"
        android:layout_height="wrap_content" 
        android:padding="18dip"
        android:layout_weight="1" 
        android:background="#424242"
        android:textColor="#ffffff"
        android:gravity="center"/>
    <Button
        android:id="@+id/btn2"
        android:text="@string/Agl"
        android:textStyle="bold"
        android:layout_width="0dip"
        android:layout_height="wrap_content" 
        android:padding="18dip"
        android:layout_weight="1" 
        android:background="#424242"
        android:textColor="#ffffff"
        android:gravity="center"/>
    <Button
        android:id="@+id/btn3"
        android:text="@string/Int"
        android:textStyle="bold" 
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:padding="18dip"
        android:layout_weight="1" 
        android:background="#424242"
        android:textColor="#ffffff"
        android:gravity="center"/>
    <Button
        android:id="@+id/btn4"
        android:text="@string/Misc"
        android:textStyle="bold" 
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1" 
        android:background="#424242"
        android:textColor="#ffffff"
        android:padding="18dip"/>
</TableRow> 
</TableLayout>

你开始了新的活动,每一个新的活动,就像一个堆栈,都在被推送。后退按钮只是完成它的实际工作,返回到最后一个活动。如果你真的想维护一个按钮栏,试试碎片


谢谢,我仔细阅读了指南,但我不知道如何用按钮栏实现这一点。有什么例子吗?提前感谢。使用带有按钮栏及以上的布局,或任何你想要的地方,放置框架布局或片段本身。这是一个很好的例子。耐心地读一读。:)别忘了把这个答案标为“接受并正确”。对我好。
 import android.app.Activity;
 import android.content.Intent;
 import android.os.Bundle;
 import android.view.View;
 import android.widget.Button;

 public class MainActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Button btn1 =(Button)findViewById(R.id.btn1);
    Button btn2 =(Button)findViewById(R.id.btn2);
    Button btn3 =(Button)findViewById(R.id.btn3);
    Button btn4 =(Button)findViewById(R.id.btn4);

    btn1.setOnClickListener(new Button.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent myIntent = new Intent();
            myIntent = new Intent(getApplicationContext(), MainActivity.class);
            myIntent.setAction(Intent.ACTION_VIEW);
            myIntent.setData(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
            setContentView(R.layout.activity_main);
            startActivityForResult(myIntent, 0);
        }
    });

    btn2.setOnClickListener(new Button.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent myIntent = new Intent();
            myIntent = new Intent(getApplicationContext(), MainAgil.class);
            myIntent.setAction(Intent.ACTION_VIEW);
            myIntent.setData(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
            setContentView(R.layout.agil_main);
            startActivityForResult(myIntent, 0);
        }
    });


    btn3.setOnClickListener(new Button.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent myIntent = new Intent();
            myIntent = new Intent(getApplicationContext(), MainInt.class);
            myIntent.setAction(Intent.ACTION_VIEW);
            myIntent.setData(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
            setContentView(R.layout.int_main);
            startActivityForResult(myIntent, 0);
        }
    });


    btn4.setOnClickListener(new Button.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent myIntent = new Intent();
            myIntent = new Intent(getApplicationContext(), MainMisc.class);
            myIntent.setAction(Intent.ACTION_VIEW);
            myIntent.setData(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
            setContentView(R.layout.misc_main);
            startActivityForResult(myIntent, 0);
        }
    });

}}