温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Dialog里面显示小框架

发布时间:2020-07-11 12:13:16 来源:网络 阅读:288 作者:671076656 栏目:移动开发

项目中少不了的小框架图

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


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI