在我的应用程序中,我有一个Seekbar显示在对话框中.现在我想设置间隔和步骤Seekbar.间隔应为0-250,每步应为5分钟.
到目前为止这是我的代码:
public class seekActivity extends Activity implements OnClickListener, OnSeekBarChangeListener {
SeekBar seekbar;
Button button;
TextView textview;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//set up main content view
setContentView(R.layout.main);
//this button will show the dialog
Button button1main = (Button) findViewById(R.id.Button01main);
button1main.setOnClickListener(this);
}
public void onClick(View v) {
//set up dialog
Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.maindialog);
dialog.setTitle("This is my custom dialog box");
dialog.setCancelable(true);
button = (Button) dialog.findViewById(R.id.Button01);
seekbar = (SeekBar) dialog.findViewById(R.id.seekBar1);
seekbar.setOnSeekBarChangeListener(this);
textview = (TextView) …Run Code Online (Sandbox Code Playgroud) 标准的通知短按会触发其中的PendingIntent.
有可能赶上其他事件吗?
要求是抓住长按.
我想在我的应用程序中使用带有搜索条的对话框.但我真的不知道怎么做,因为我缺乏android的经验.
因此,当您按下按钮时:应该出现一个对话框,其中有一个搜索栏,用户可以输入一个值然后按OK按钮.
我目前的代码是developer.android的默认代码:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure you want to exit?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
MyActivity.this.finish();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能添加SeekBar?
谢谢!
我试图通过从麦克风获取实时输入来获得声级.
作为应用程序,如声音计和deciBel.我从链接中找到了这个示例代码:
我也在这里粘贴它.
package com.google.android.noisealert;
import android.media.MediaRecorder;
public class SoundMeter {
static final private double EMA_FILTER = 0.6;
private MediaRecorder mRecorder = null;
private double mEMA = 0.0;
public void start() {
if (mRecorder == null) {
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setOutputFile("/dev/null");
mRecorder.prepare();
mRecorder.start();
mEMA = 0.0;
}
}
public void stop() {
if (mRecorder != null) {
mRecorder.stop();
mRecorder.release();
mRecorder = null;
}
}
public double getAmplitude() {
if (mRecorder != null)
return (mRecorder.getMaxAmplitude()/2700.0);
else …Run Code Online (Sandbox Code Playgroud) 我对android很陌生,我已经搜索了很长一段时间。我想构建一个类似于分贝计的应用程序。它实时显示声级。如果房间里有很多噪音,就会有什么迹象表明,如果它安静,就会有什么迹象表明!。
我根本不知道如何做到这一点。谁能解释一下麦克风声级应用程序的基础知识?如果可能的话,也许提供一些代码?
谢谢!
我想得到你们的一些帮助,设计.我一直在研究android的应用程序,有一段时间了,剩下的是设计部分.经过几个小时的尝试和工作后,我意识到我实际上并不是那么擅长.
所以,我想问你们所有人:
你从哪里得到你的主要想法?
你是怎么开始的?
重要的是要考虑,强调,等等?
还有其他提示吗?
谢谢!