溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Dialog里面顯示小框架

發(fā)布時(shí)間:2020-07-11 12:13:16 來(lái)源:網(wǎng)絡(luò) 閱讀:298 作者:671076656 欄目:移動(dòng)開(kāi)發(fā)

項(xiàng)目中少不了的小框架圖

public void showLayout(){

AlertDialog.Builder dialog = new AlertDialog.Builder(SmallMainActivity.this);//當(dāng)前的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();//這一句是用來(lái)顯示的,不能少

}

// 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" />


向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI