ダイアログにシークバーを付ける [Dialog]
//レイアウト seekdialog.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/dialog_root" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"> <SeekBar android:id="@+id/seekbar" android:layout_width="fill_parent" android:layout_height="wrap_content" > </SeekBar> </LinearLayout>
//Activity内
LayoutInflater inflater = LayoutInflater.from(this); seekView = inflater.inflate(R.layout.seekdialog, (ViewGroup) findViewById(R.id.dialog_root)); seekbar = (SeekBar) seekView.findViewById(R.id.seekbar); seekbar.setMax(100); seekbar.setProgress(50); seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { public void onStopTrackingTouch(SeekBar seekBar) { } public void onStartTrackingTouch(SeekBar seekBar) { } public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { //progressにシークの値が来る } }); Dialog dialog = new AlertDialog.Builder(this) .setTitle("seekbar") .setView(seekView) .setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).create(); dialog.show();
ColorPickerDialogを使う [Dialog]
標準に用意されていないので、APIDemoにあるcom.example.android.apis.graphics.ColorPickerDialog を使います。
まず、ColorPickerDialog.java を自分のプログラムの任意のパッケージにコピーしてから。
ColorPickerDialog colorPickerDialog = new ColorPickerDialog( MainActivity.this, new ColorPickerDialog.OnColorChangedListener() { @Override public void colorChanged(int color) { //colorが選択された色 } }, Color.BLACK); colorPickerDialog.show();
【送料無料】ゼロからのAndroidアプリケ-ション開発入門
- ショップ: 楽天ブックス
文字を入力するダイアログを作成する。 [Dialog]
mEditText = new EditText(getApplicationContext()); new AlertDialog.Builder(this).setTitle("Question") .setView(mEditText) .setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mIP = mEditText.getText().toString(); } }).show();
Every Little Thing CD+DVD【アイガアル】11/8/24発売
- ショップ: アットマークジュエリーMusic
タグ:Dialog