活动本身使用表格布局,以避免RatingBar的fill_parent宽度(这会影响启动次数)我在TableLayout中放置了一个LinearLayout,并将ratingBar放在其中。对齐和一切都很好,但是RatingBar不再响应被按下(我有一个OnRatingBarChangeListener)。它在线性布局之外工作得很好,我现在需要调整一些东西到达评级栏吗?
设置评级栏
ratingBar = (RatingBar) findViewById(R.id.ratingRatingBar);
设置监听器
ratingBar.setOnRatingBarChangeListener(changeRating);
听众本身(可能很好)
private OnRatingBarChangeListener changeRating = new OnRatingBarChangeListener()//function that updates the rating
{
@Override
public void onRatingChanged(RatingBar ratingBar, float rating,
boolean fromUser) {
// TODO Auto-generated method stub
int currentRating = (int) ratingBar.getRating();//gets the rating on the bar
dataSource.open();
dataSource.updateRating((int) currentMovie.getId(), currentRating);//updates the entries rating with the new one
dataSource.close();
}
};
和xml
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/TableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal" >
<TextView
android:id="@+id/nameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/descTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<VideoView
android:id="@+id/trailerVideoView"
android:layout_width="match_parent"
android:layout_height="200dp" />
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<Button
android:id="@+id/reverseButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/ReverseString" />
<Button
android:id="@+id/pauseButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/pauseString" />
<Button
android:id="@+id/playButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/playString" />
</TableRow>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical" >
<RatingBar
android:id="@+id/ratingRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:isIndicator="true"
android:numStars="5"
android:stepSize="1" />
</LinearLayout>
<Button
android:id="@+id/backToStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/GoBackString" />
<Button
android:id="@+id/deleteCurrentButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/deleteText" />
</TableLayout>
答案 0 :(得分:0)
我发现了我的问题,一个愚蠢的问题
android:isIndicator="true"
阻止用户与之交互,只是我没有意识到的设置。