我试图在文本视图中显示用户的评分,而我得到的只是“进程意外终止”错误。一共有三个活动。包含评分栏的活动的 XML 编码是
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
tools:context=".RatingActivity" >
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:hint="@string/hello_world"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
java编码是:
package com.example.myfirstapp;
import android.app.Activity;
import android.os.Bundle;
import android.widget.RatingBar;
import android.widget.TextView;
public class RatingActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rating);
RatingBar ratingBar1=(RatingBar)findViewById(R.id.ratingBar1);
TextView textView3 =(TextView) findViewById(R.id.textView3);
textView3.setTextSize(40);
textView3.setText("Rating is :"+ratingBar1.getRating());
}
}
我究竟做错了什么?我是android应用程序开发的新手。请帮助,提前谢谢。