我正在尝试在单个活动中实现多个搜索栏
过滤器.java
public class Filters extends Activity implements OnSeekBarChangeListener{
private SeekBar PRICEbar,DISTANCEbar, RATINGbar; // declare seekbar object variable
// declare text label objects
private TextView PRICEtextProgress,DISTANCEtextProgress, RATINGtextProgress;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// load the layout
setContentView(R.layout.filters);
PRICEbar = (SeekBar)findViewById(R.id.PRICEseekBarID); // make seekbar object
PRICEbar.setOnSeekBarChangeListener(this); // set seekbar listener.
// since we are using this class as the listener the class is "this"
// make text label for progress value
PRICEtextProgress = (TextView)findViewById(R.id.PRICEtextViewProgressID);
// make text label for action
//textAction = (TextView)findViewById(R.id.textViewAction);
////////////////////////////////////////////////////////
DISTANCEbar = (SeekBar)findViewById(R.id.DISTANCEseekBarID); // make seekbar object
DISTANCEbar.setOnSeekBarChangeListener(this);
DISTANCEtextProgress = (TextView)findViewById(R.id.DISTANCEtextViewProgressID);
////////////////////////////////////////////////////////
RATINGbar = (SeekBar)findViewById(R.id.RATINGseekBarID); // make seekbar object
RATINGbar.setOnSeekBarChangeListener(this);
RATINGtextProgress = (TextView)findViewById(R.id.RATINGtextViewProgressID);
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// TODO Auto-generated method stub
// change progress text label with current seekbar value
PRICEtextProgress.setText("Price:: Rs "+progress);
// change action text label to changing
//textAction.setText("changing");
DISTANCEtextProgress.setText("Distance:: "+progress);
RATINGtextProgress.setText("Rating:: "+progress);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
//textAction.setText("starting to track touch");
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
seekBar.setSecondaryProgress(seekBar.getProgress());
//textAction.setText("ended tracking touch");
}
}
过滤器.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/relativeLayoutforPRICE"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/PRICEtextViewProgressID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Price"
android:textAppearance="?android:attr/textAppearanceLarge" >
</TextView>
<SeekBar
android:id="@+id/PRICEseekBarID"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:layout_marginTop="26dp"
android:max="100" >
</SeekBar>
</RelativeLayout>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="@android:color/black" />
<RelativeLayout
android:id="@+id/relativeLayoutforDISTANCE"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/DISTANCEtextViewProgressID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="DISTANCE"
android:textAppearance="?android:attr/textAppearanceLarge" >
</TextView>
<SeekBar
android:id="@+id/DISTANCEseekBarID"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:layout_marginTop="26dp"
android:max="100" >
</SeekBar>
</RelativeLayout>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="@android:color/black" />
<RelativeLayout
android:id="@+id/relativeLayoutforRATING"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/RATINGtextViewProgressID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Rating"
android:textAppearance="?android:attr/textAppearanceLarge" >
</TextView>
<SeekBar
android:id="@+id/RATINGseekBarID"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:layout_marginTop="26dp"
android:max="100" >
</SeekBar>
</RelativeLayout>
</LinearLayout>
我们可以清楚地知道,无论哪个搜索栏,我都会立即更改所有更改的值
我该如何解决这个问题?
另外,我怎样才能让评级搜索栏接受像
( 1,2,3,4,5 )
而不是(1234..100)
有任何想法吗 ?