combwattle / range-seek-bar

Automatically exported from code.google.com/p/range-seek-bar
0 stars 0 forks source link

your example file error #10

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
public class MyActivity extends ListActivity {

...
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
...
        Context context;
        // create RangeSeekBar as Integer range between 20 and 75
        RangeSeekBar<Double> seekBar = new RangeSeekBar<Double>(0.0, 100.0, context);

        seekBar.setOnRangeSeekBarChangeListener(new OnRangeSeekBarChangeListener<Double>() {
                @Override
                public void onRangeSeekBarValuesChanged(RangeSeekBar<?> bar, Double minValue, Double maxValue) {
                        // handle changed range values
                        Log.i(TAG, "User selected new range values: MIN=" + minValue + ", MAX=" + maxValue);
                }
        });

ERROR:
The method 
     setOnRangeSeekBarChangeListener(RangeSeekBar.OnRangeSeekBarChangeListener<Double>) in the type 
     RangeSeekBar<Double> is not applicable for the arguments (new OnRangeSeekBarChangeListener<Double>()
     {})

OnRangeSeekBarChangeListener cannot be resolved to a type

-------
if i changed to this:

seekBar.setOnRangeSeekBarChangeListener(seekBar.new 
OnRangeSeekBarChangeListener<Double>() {

i get another error:
Illegal enclosing instance specification for type 
RangeSeekBar<Double>.OnRangeSeekBarChangeListener<Double>

--------
so how to use this range seekbar?

Original issue reported on code.google.com by abloz...@gmail.com on 12 May 2012 at 10:44

GoogleCodeExporter commented 9 years ago
Hi ablozhou,

in Java, you need to "declare" all classes being used either by importing them 
or by refering to them with there fully qualified name. So you have two choices 
to make it work:

1. import the inner class "OnRangeSeekBarChangeListener":

import <your-package-name>.RangeSeekBar.OnRangeSeekBarChangeListener;

2. Import class "RangeSeekBar" and refer to "OnRangeSeekBarChangeListener" the 
following way:

seekBar.setOnRangeSeekBarChangeListener(new 
RangeSeekBar.OnRangeSeekBarChangeListener<Double>() { ...

Original comment by tittel@kom.e-technik.tu-darmstadt.de on 14 May 2012 at 8:04

GoogleCodeExporter commented 9 years ago
hey hii i am tejas i am gatting an errror in [seekBar = (seekBar) 
findViewById(R.id.SeekBar01);] code and in [mediaPlayer = 
MediaPlayer.create(this,R.raw.testsong_20_sec);]code

the error is in raw word and in line of [findViewById(R.id.SeekBar);

i am giving u the whole set of code also below:

package teja.MusicPlayer.main;

import teja.MusicPlayer.main.R;

import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Handler;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.SeekBar;

public class MusicPlayerActivity extends Activity {

    private Button buttonPlayStop;
    private MediaPlayer mediaPlayer;
    private SeekBar seekBar;

    private final Handler handler = new Handler();

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

    }

    private void initView(){
        buttonPlayStop = (Button) findViewById(R.id.ButtonPlayStop);
        buttonPlayStop.setOnClickListener(new OnClickListener() {
            public void onClick(View v){buttonClick();}});

        mediaPlayer = MediaPlayer.create(this,R.raw.testsong_20_sec);

        seekBar = (seekBar) findViewById(R.id.SeekBar01);
        seekBar.setMax(mediaPlayer.getDuration());
        seekBar.setOnTouchListener(new OnTouchListener() { 
            public boolean onTouch(View v, MotionEvent arg1) {
                // TODO Auto-generated method stub
                seekChange(v);
                return false;
            }
        });

    }
    public void startPlayProgressUpdater() {
        seekBar.setProgress(mediaPlayer.getCurrentPosition());

        if (mediaPlayer.isPlaying()) {
            Runnable notification = new Runnable() {
                public void run() {
                    startPlayProgressUpdater();

                }
            };
            handler.postDelayed(notification,1000);
        }else{
            mediaPlayer.pause();
            buttonPlayStop.setText(getString(R.string.play_str));
            seekBar.setProgress(0);
        }
    }

    private void seekChange(View v){
        if(mediaPlayer.isPlaying()){
            SeekBar sb = (SeekBar)v;
            mediaPlayer.seekTo(sb.getProgress());

        }
    }

    private void buttonClick(){
        if (buttonPlayStop.getText() == getString(R.string.play_str)) {
            buttonPlayStop.setText(getString(R.string.pause_str));
            try{
                mediaPlayer.start();
                startPlayProgressUpdater();
            }catch (IllegalStateException e) {
                mediaPlayer.pause();
            }
        }else{
            buttonPlayStop.setText(getString(R.string.play_str));
            mediaPlayer.pause();
        }
    }
}
        plzzzz tell me the solution to get reed of this problem.....

Original comment by Tejas...@gmail.com on 1 Jun 2012 at 4:25