2012-09-14 2 views
0

버튼을 클릭 한 후 seekbar를 팝업 할 사용자 정의 토스트를 만들고 싶습니다.사용자 정의 토스트가 안드로이드에 액티비티 또는 기능을 포함합니다.

사용자 정의 토스트의 탐색 모음이 나타나지만 탐색 모음의 진행을 이동할 수 없습니다. 이 코드에 대한

enter image description here

을 표시하는 방법

이이 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(); 

} 
+0

'토스트 (Toast)'를 클릭 할 수없는 '토스트 (toast)'는 사용자에게 상호 작용없이 보여지는 간단한보기이며, 원하는 것을 의미하지 않습니다. – Luksprog

답변

0

토스트는 터치 이벤트를 수신 할 수 없습니다. 코드의 Toast 부분을 제거하고 Activity의 내용에 View를 직접 추가하십시오.

LayoutInflater mLayoutInflater = (LayoutInflater) 
    getSystemService(Context.LAYOUT_INFLATER_SERVICE); 

ViewGroup mViewGroup = (ViewGroup) 
    findViewById(android.R.id.content); 

View mView = mLayoutInflater.inflate(R.layout.yourlayout, 
    mViewGroup, false); 

mViewGroup.addView(mView); 
관련 문제