我正在尝试更改我的活动TextView
中使用的文本大小。ListView
但它在运行时显示错误。
我的活动
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
settings();
// Check Full Screen
if (Fullscreen_Sett == true) {
// hide statusbar of Android
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
// Content View
setContentView(R.layout.tutoriallist_layout);
// Backlight ON/OFF
if (Backlight_Sett == true) {
getWindow()
.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
// ActionBar
ActionBar ActionBar = getSupportActionBar();
ActionBar.setTitle("Tutorials");
ActionBar.setDisplayHomeAsUpEnabled(true);
ActionBar.setHomeButtonEnabled(true);
// load the animation
animfade_in = AnimationUtils.loadAnimation(getApplicationContext(),
R.anim.fade_in);
animfade_out = AnimationUtils.loadAnimation(getApplicationContext(),
R.anim.fade_out);
// *********load the animation
// ***********Set TextSize Of List
TextView tv = (TextView)findViewById(R.id.tutoriallist_text_ID);
tv.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_Small);
// Strings
final String[] TutorialArray = getResources().getStringArray(
R.array.Tutorial_Array);
// List View Import
lv = (ListView) findViewById(R.id.tutorial_listview);
// Adding items to listview
adapter = new ArrayAdapter<String>(this, R.layout.tutoriallist_text,
R.id.tutoriallist_text_ID, TutorialArray);
lv.setAdapter(adapter);
if (Animation_Sett == true) {
// Check Animation
lv.startAnimation(animfade_in);
}
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
if (arg2 == 0) {
Toast.makeText(getApplicationContext(), "Tutorial",
Toast.LENGTH_SHORT).show();
}
}
});
}
我的 XML 文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/tutoriallist_text_ID"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/tutorialliststyle"
android:gravity="center"
android:lines="2"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="20sp"
android:typeface="monospace" />
</LinearLayout>
日志猫:
08-01 11:10:34.744: E/AndroidRuntime(3826): FATAL EXCEPTION: main
08-01 11:10:34.744: E/AndroidRuntime(3826): android.content.res.Resources$NotFoundException: Resource ID #0x7f060038 type #0x12 is not valid
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2144)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.content.res.Resources.getLayout(Resources.java:853)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:371)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.widget.AbsListView.obtainView(AbsListView.java:2159)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.widget.ListView.measureHeightOfChildren(ListView.java:1246)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.widget.ListView.onMeasure(ListView.java:1158)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.view.View.measure(View.java:15513)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.view.View.measure(View.java:15513)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.view.View.measure(View.java:15513)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.widget.LinearLayout.measureVertical(LinearLayout.java:847)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.view.View.measure(View.java:15513)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
08-01 11:10:34.744: E/AndroidRuntime(3826): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2176)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.view.View.measure(View.java:15513)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1874)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1089)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1265)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.view.Choreographer.doFrame(Choreographer.java:532)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.os.Handler.handleCallback(Handler.java:725)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.os.Handler.dispatchMessage(Handler.java:92)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.os.Looper.loop(Looper.java:137)
08-01 11:10:34.744: E/AndroidRuntime(3826): at android.app.ActivityThread.main(ActivityThread.java:5039)
08-01 11:10:34.744: E/AndroidRuntime(3826): at java.lang.reflect.Method.invokeNative(Native Method)
08-01 11:10:34.744: E/AndroidRuntime(3826): at java.lang.reflect.Method.invoke(Method.java:511)
08-01 11:10:34.744: E/AndroidRuntime(3826): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
08-01 11:10:34.744: E/AndroidRuntime(3826): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
08-01 11:10:34.744: E/AndroidRuntime(3826): at dalvik.system.NativeStart.main(Native Method)
注意:我也尝试过 tv.settextsize() 和其他。但它仍然是相同的错误......