我想在活动中应用滑块动画意味着当用户单击按钮时,下一个屏幕将打开滑块动画。
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.