我有两个类,其中一个包含我想要应用的动画。 但由于未知的原因,它不起作用。
我的主要课程:
package com.example.tachles;
import android.os.Bundle;
import android.text.Html;
import android.text.Spanned;
import android.view.Menu;
import android.view.MenuItem;
public class History_01_01 extends TextSet {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String formattedText = getString(R.string.zionut01);
Spanned result = Html.fromHtml(formattedText);
text.setText(result);
}
public void sizeUp(MenuItem item) {
super.sizeUp(item);
}
public void sizeDown(MenuItem item) {
super.sizeDown(item);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.textbar, menu);
return true;
}
@Override
protected void onStart() {
super.onStart();
}
@Override
protected void onStop() {
super.onStop();
}
}
我要扩展的课程
package com.example.tachles;
import android.app.ActionBar;
import android.app.Activity;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
public class TextSet extends Activity {
TextView text;
float size;
ActionBar actionBar;
private final String TEXT_SIZE = "textsize";
final String MyPref = "preference";
SharedPreferences settings;
Editor editor;
int onStartCount = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.textpage);
text = (TextView) findViewById(R.id.textView1);
settings = this.getSharedPreferences(MyPref, 0);
text.setTextSize(settings.getFloat(TEXT_SIZE, 15));
editor = settings.edit();
onStartCount = 1;
if (savedInstanceState == null) {
this.overridePendingTransition(R.anim.anim_slide_in_left,
R.anim.anim_slide_out_left);
} else {
onStartCount = 2;
}
}
public void sizeUp(MenuItem item) {
size = text.getTextSize();
if (size < 80) {
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (size + 7));
}
}
public void sizeDown(MenuItem item) {
size = text.getTextSize();
if (size > 25) {
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (size - 7));
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.textbar, menu);
return true;
}
@Override
protected void onStart() {
super.onStart();
if (onStartCount > 1) {
this.overridePendingTransition(R.anim.anim_slide_in_right,
R.anim.anim_slide_out_right);
} else if (onStartCount == 1) {
onStartCount++;
}
}
@Override
protected void onStop() {
super.onStop();
SharedPreferences.Editor editor = settings.edit();
editor.putFloat(TEXT_SIZE, text.getTextSize()
/ getResources().getDisplayMetrics().scaledDensity);
editor.commit();
}
}
没有错误,它运行正常,但没有动画...... 我在另一个类上使用相同的动画,xml没有问题。