我想在单击一个按钮时更改 TextView 的大小,该按钮又调用弹出搜索栏对话框。
为清楚起见,请参见图片。
我在如何在警报对话框中放置搜索栏?并在自定义警报对话框内的文本视图中显示搜索栏的进度以查找解决方案,这是我的代码:
btn_font.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.dialog_change_fontsize,
(ViewGroup) findViewById(R.id.layout_viewdetailcontent));
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ViewDetailActivity.this)
.setView(layout);
final SeekBar sb = (SeekBar) layout.findViewById(R.id.seekBar1);
sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seekBar,
int progress, boolean fromUser) {
// Do something here with new value
p = progress;
tv_content.setTextSize(p);
}
@Override
public void onStartTrackingTouch(SeekBar arg0) {
// TODO Auto-generated method stub
p = 16;
tv_content.setTextSize(p);
}
@Override
public void onStopTrackingTouch(SeekBar arg0) {
// TODO Auto-generated method stub
if (p < 16) {
p = 16;
sb.setProgress(p);
}
Toast.makeText(getBaseContext(), String.valueOf(p),
Toast.LENGTH_SHORT).show();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
});
但不工作。请帮我找出我做错了什么。提前致谢。