1

ユーザーがボタンをクリックすると、次の画面がスライダーアニメーションで開きます。

TEST2Activity.java

public class TEST2Activity extends Activity {
    EditText dob;
    Button btn;
    SimpleDateFormat dateformat;
    Editable
    var;
    String str;

    /** Called when the activity is first created. */@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        //  isOnline();
        Date date = new Date();
        date.getDate();
        dateformat = new SimpleDateFormat("dd-mm-yyyy");
        dob = (EditText) findViewById(R.id.dob);


        btn = (Button) findViewById(R.id.button1);

        str = dob.getText().toString();
        System.out.println("date is string" + str);
        System.out.println("date is string");
        btn.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                try {

                    Intent intent = new Intent(TEST2Activity.this, CommentChangeActivity.class);

                    startActivity(intent);


                    overridePendingTransition(R.anim.myslideleft, R.anim.myslideright);
                } catch (Exception e) {
                    System.out.println("the error in date is" + e);
                }
            }
        });
    }

    public boolean isOnline() {
        ConnectivityManager cm = (ConnectivityManager) getSystemService(this.CONNECTIVITY_SERVICE);
        NetworkInfo ni = cm.getActiveNetworkInfo();
        boolean result = false;
        if (ni != null) {
            if (ni.getState() == NetworkInfo.State.CONNECTED) {
                result = true;
            }
        }
        System.out.println("the internet connected is:" + result);
        return result;

    }
}    

CommentChangeActivity.java

public class CommentChangeActivity extends Activity {
    EditText showCategoryValue;
    EditText showItemValue;
    EditText showCommentValue;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.myfile);
    }
} 

左の xml にスライド

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

    <translate
        android:duration="2000"
        android:fromXDelta="-50%p"
        android:toXDelta="0" />

    <alpha
        android:duration="2000"
        android:fromAlpha="0.0"
        android:toAlpha="1.0" />

</set>  

右側の xml にスライド

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

    <translate
        android:duration="2000"
        android:fromXDelta="50%p"
        android:toXDelta="0" />

    <alpha
        android:duration="2000"
        android:fromAlpha="0.0"
        android:toAlpha="1.0" />

</set>

そしてアクティビティコードで:

    startActivity(intent);
    overridePendingTransition(R.anim.slide_in_left, R.anim.slide_in_right);  


i have use this code but it doesn't work so please suggest me the solution of it.
helpers must be appreciated and thanks in advance. 
4

1 に答える 1

0

これを試して:

左の 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="300"/>
</set>

この

左の xml をスライドアウト:

  <?xml version="1.0" encoding="utf-8"?>
  <set xmlns:android="http://schemas.android.com/apk/res/android">
      <translate android:fromXDelta="0" android:toXDelta="-100%p" android:duration="300"/>
  </set>

コードは次のようになります。

  overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left);  
于 2012-07-02T10:43:08.653 に答える