0
我想制作自定义吐司在哪里将点击按钮后弹出seekbar。自定义吐司包括活动或功能在android
自定义吐司中的seekbar出现,但是seekbar的进度无法移动。
这是怎么出现
的代码,这是搜索条的活动。
package com.example.froyo2;
import android.app.Activity;
import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;
public class BloodpressureActivity extends Activity implements OnSeekBarChangeListener{
private SeekBar bar; // declare seekbar object variable
// declare text label objects
private TextView textProgress,textAction;
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.bloodpressure);
bar = (SeekBar)findViewById(R.id.seekBar1);
bar.setOnSeekBarChangeListener(this);
textProgress = (TextView) findViewById(R.id.textViewProgress);
textAction = (TextView) findViewById(R.id.textViewAction);
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// change progress text label with current seekbar value
textProgress.setText("The value is: "+progress);
Toast.makeText(this, "Progress: " +progress, 2500).show();
// change action text label to changing
textAction.setText("changing");
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
textAction.setText("starting to track touch");
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
seekBar.setSecondaryProgress(seekBar.getProgress());
textAction.setText("ended tracking touch");
}
}
这是按钮的侦听器,点击按钮后它将出现自定义的烤面包。
public void onClick(View v){
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.bloodpressure, (ViewGroup) findViewById(R.id.seekBar1));
Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.BOTTOM, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
}
你不能点击'Toast','Toast'是一个简单的视图,显示给用户没有交互,它不是为了你想要做的。 – Luksprog