0

これが私のコードです:

public class ScoreFragment extends Fragment {

public static final String TAG ="ScoreFragment";

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        Log.d(TAG, "onAttach");

    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if(savedInstanceState==null)
        {
            Log.d(TAG,"onCreate FIRST TIME");
        }
        else
        {
            Log.d(TAG,"onCreate SUBSEQUENT TIME");
        }

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater,container,savedInstanceState);
        final View v = inflater.inflate(R.layout.score_collection, container, false);

        final TextView sliderText = (TextView) v.findViewById(R.id.score_number);
        sliderText.setTextSize(48);

        //TODO: Find solution to find known bug in Android
       /* ActionBar  actionBar = ((ActionBarActivity) getActivity()).getSupportActionBar();
        actionBar.hide();*/

        SeekBar seekbar = (SeekBar) v.findViewById(R.id.seekBar);

        seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

                sliderText.setText("" + progress);
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }
        });


        Log.d(TAG,"onCreateView");
        return inflater.inflate(R.layout.score_collection, container, false);

    }

seekBar は表示されますが、ビューにテキストが増えたり表示されたりしません。

私のビュー(RelativeLayout内)で設定する方法は次のとおりです。

 <SeekBar
            android:layout_width="300sp"
            android:layout_height="wrap_content"
            android:id="@+id/seekBar"
            android:progress="0"
            android:max="10"
            android:minHeight="30sp"
            android:maxHeight="30sp"
            android:layout_below="@+id/score_number" 
            android:layout_centerHorizontal="true"/>

フラグメントに配置する前に実際に機能したので、フラグメント内にあることに関係していると思いますが、完全にはわかりません。

0 から 10 のスケールで 1 ずつインクリメントすることを想定しています。

4

1 に答える 1