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