您好,登錄后才能下訂單哦!
項目中少不了的小框架圖
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" />
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。