1

活动本身使用表格布局,为了避免 RatingBar 的 fill_parent 宽度(这会弄乱启动次数),我在 TableLayout 内放置了一个 LinearLayout,并将 ratingBar 放在其中。现在对齐和一切都很好,但是 RatingBar 不再响应被按下(我有一个 OnRatingBarChangeListener)。它在线性布局之外工作正常,我现在需要调整什么才能进入评分栏吗?

设置评分栏

ratingBar = (RatingBar) findViewById(R.id.ratingRatingBar);

设置监听器

ratingBar.setOnRatingBarChangeListener(changeRating);

Listener 本身(可能没问题)

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>
4

1 回答 1

0

我发现了我的问题,一个愚蠢的问题

android:isIndicator="true"

阻止用户与之交互,这只是我没有意识到的设置。

于 2013-12-07T13:00:41.693 回答