1

アクティビティ自体は、RatingBar の fill_parent 幅 (開始数を台無しにする) を避けるために、テーブル レイアウトを使用します。TableLayout 内に LinearLayout を配置し、その中に ratingBar を配置しました。位置合わせとすべてが問題ありませんが、RatingBar が押されても応答しなくなりました (私は OnRatingBarChangeListener を持っています)。Linear Layout の外からは問題なく動作していましたが、評価バーに到達するために調整する必要があるものはありますか?

評価バーの設定

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

1 に答える 1

0

私の問題、ばかげた問題を見つけました

android:isIndicator="true"

ユーザーがそれを操作できないようにします。これは、私が気づかずに行っていた設定です。

于 2013-12-07T13:00:41.693 に答える