Dialog里面显示小框架

项目中少不了的小框架图

public void showLayout(){

AlertDialog.Builder dialog = new AlertDialog.Builder(SmallMainActivity.this);//当前的Context

AlertDialog alert = dialog.create();

LayoutInflater inflater = alert.getLayoutInflater();

View view = inflater.inflate(R.layout.test_layout, null);//

alert.setView(view);

final Button btn = (Button) view.findViewById(R.id.button1_test);

final TextView text = (TextView) view.findViewById(R.id.textView1);

final SeekBar seekbar = (SeekBar) view.findViewById(R.id.seekBar1);

btn.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View arg0) {

// TODO Auto-generated method stub

Toast.makeText(SmallMainActivity.this, "click", Toast.LENGTH_LONG).show();

}

});

seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

@Override

public void onStopTrackingTouch(SeekBar seekBar) {

// TODO Auto-generated method stub

}

@Override

public void onStartTrackingTouch(SeekBar seekBar) {

// TODO Auto-generated method stub

}

@Override

public void onProgressChanged(SeekBar seekBar, int progress,

boolean fromUser) {

// TODO Auto-generated method stub

text.setText(progress + "");

}

});

alert.show();//这一句是用来显示的,不能少

}

// res/layout 下的 test_layout.xml布局

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical" >

   

        android:id="@+id/textView1"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:text="0" />

   

        android:id="@+id/seekBar1"

        android:layout_width="match_parent"

        android:layout_height="wrap_content" />

   

        android:id="@+id/button1_test"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:text="Button" />

   

        android:id="@+id/ratingBar1"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content" />