我想知道android FutureTask和AsyncTaskandroid 之间的区别.根据我的想法,我们可以在FutureTask中获得当前的情况.使用ExecutorService我们可以创建一个并行进程池.我们可以使用AsyncTask实现相同的属性.我想知道在哪里使用AsyncTask以及何时使用FutureTask的情况.
我在这里问过一个问题 ,但没有得到任何答复.现在我想我应该改变我获取webservices数据的方式.所以我认为我应该使用FutureTask因为它们具有像isDone()这样的功能
并取消.请一些人指导我从网络服务中检索数据的更好方法.因为我的textView设置适配器太慢了.
或者我只需要一种方法来取消正在运行的AsyncTasks或用当前替换它.当用户按下w它呼吁的AsyncTask,当他在AutotextView添加任何词来它会三次要求waka之一wa,并wak和一个waka.当用户按下另一个文本时,是否可以取消正在运行的任务.有关详情,请参阅我的问题.
我想知道什么是标志(或标志的可能值是什么)
audiomanager.setStreamVolume(int streamType,int index,int flags);
我知道我们可以使用最大流
audiomanger.getMaxStream(audioManager.getStreamMax(AudioManager.STREAM_MUSIC));
但在某些设备中它给出了13,15,这取决于Android版本或设备硬件以及它的范围是什么(最小可能值,最大可能值)
设置特定流的卷索引.
如果设备实现了isVolumeFixed()所指示的固定卷策略,则此方法无效.//这是什么意思.
参数
streamType The stream whose volume index should be set.
index The volume index to set. See getStreamMaxVolume(int) for the largest valid value.
flags One or more flags. // what are these flags
Run Code Online (Sandbox Code Playgroud) 我已经解决了一些问题,但没有解决我的问题.
我创建了一个自定义DialogFragment.和根元素dialog is cardView.我设置cardCornerRadius的cardView.
然后我尝试设置透明对话框,因为背景颜色也随之显示.
然后我尝试设置对话框主题
<style name="PauseDialog" parent="@style/Theme.AppCompat.Light.Dialog">
<!-- TTheme.AppCompat.Translucent-->
<item name="android:windowAnimationStyle">@style/PauseDialogAnimation</item>
<!--<item name="android:windowBackground">@android:color/transparent</item>-->
<item name="android:windowBackground">@color/transparent</item>
<item name="android:colorBackgroundCacheHint">@android:color/transparent</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowTitleStyle">@null</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:background">@android:color/transparent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
背景仍然存在.然后我也试过了
dialog.getWindow().setBackgroundDrawable(
new ColorDrawable(Color.TRANSPARENT));
Run Code Online (Sandbox Code Playgroud)
但仍然对话框有与之相关的背景.
有什么工作吗?我怎么能摆脱它.
我创建了一个DialogFragment和onCreateDialog
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(),
R.style.PauseDialog);
setStyle(DialogFragment.STYLE_NO_FRAME, R.style.PauseDialog);
Run Code Online (Sandbox Code Playgroud)
我已将FocusChangeListener添加到
EditText. 喜欢
etZip.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if(!hasFocus)
{
callAreaDetailService(zipCode,false);
}
}
});
Run Code Online (Sandbox Code Playgroud)
现在,如果我focus打开了etZip,我点击Button进入anotherActivity。etZip 失去焦点并在下一个活动中显示响应警报。
我知道我可以添加一个标志,以便在单击按钮时boolean不调用。service但我确信必须有一种android内置方法来阻止焦点变化。
没有function喜欢的etZip.removeFocusChangeListener。那么有没有办法使用Android SDK来做到这一点。
我想减少阅读次数,以便从
QuestionCollection(Array of Questions) 中获取问题的详细信息。
我的应用程序就像是 stackoverflow 的一部分。
我想显示一个问题有多少赞、浏览量和评论。所以为了处理这个我创建了多个集合
问题集
评论集
问题点赞
问题视图
问题标签
我认为CommentCollection (comments) 只属于一个问题。所以我正在考虑QuestionCollection像数组或集合一样合并(但它需要另一个读取命中)。哪个更好?
我想totalViews,totalLikes在 QuestionCollection中添加两个变量的( )。但是每次我都必须检查这个问题是否被这个用户喜欢或被这个用户查看。
给我一个建议或替代方案,这样我就可以尽可能少地获取问题详细信息。
编辑
为了显示视图计数, 我迭代并计算QuestionViews 集合,其中 questionID == myQuestionID
为了显示喜欢计数, 我迭代并计算QuestionLikes 集合,其中 questionID == myQuestionID
为什么我不将它添加到 QuestionCollection?因为我想展示最多查看和最喜欢的问题,例如 stackoverflow。如果我将它添加到 QuestionCollection 我怎么知道最喜欢和最多查看的问题。
我想使用Speech Recongnition来处理我的应用程序中的命令.我知道在我的应用程序中的任何给定点,有效命令在那一点上是什么,所以希望限制语音识别匹配的结果.
我的意思是在我的应用程序..有效的单词只是数字加字母.我的意思A13FG6是像这样的数字.
我希望能够限制语音识别只能尝试匹配alphaNumeric词.限制词汇量会增加其成功的机会..
我怎么能修改给定的代码来满足我的要求
提前致谢..
import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.speech.RecognitionListener;
import android.speech.RecognizerIntent;
import android.speech.SpeechRecognizer;
import android.util.Log;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends Activity {
private TextView mText;
private SpeechRecognizer sr;
private static final String TAG = "MyStt3Activity";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button speakButton = (Button) findViewById(R.id.btn_speak);
mText = (TextView) findViewById(R.id.textView1);
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
getClass().getPackage().getName());
SpeechRecognizer recognizer = SpeechRecognizer
.createSpeechRecognizer(this.getApplicationContext());
RecognitionListener listener …Run Code Online (Sandbox Code Playgroud) 我只是想知道.有没有办法使用for循环创建一个id
我在xml中有10个按钮.有ID是button1,button2,button3... button10 现在,我创建按钮的数组中java class,并像这样做
public class Menu extends Activity
{
Button[] arrayButton=new Button[10];
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.menu);
init();
}
private void init()
{
for(int i=1 ; i<9 ; i++)
{
String abc = "but"+String.valueof(i);
int x = Integer.parseInt(abc);
Log.d("abc", abc);
Log.d("x", String.valueOf(x) );
//arrayButton[i] = (Button) findViewById(R.id.x); // giving error
//arrayButton[i].setText("Hello:");
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想知道我该怎么做这种工作.使用for循环获取所有按钮可以使我的工作更快,有时我想设置所有按钮的文本.
android view r.java-file android-resources android-identifiers
我想在旋钮周围显示进度条。遵循本教程后,我创建了这个
旋钮工作正常。
但是我怎样才能修改上面的旋钮使其看起来像第二张图片
第一个旋钮的运行代码如下所示。
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.RectF;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.View.MeasureSpec;
import android.view.MotionEvent;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.RelativeLayout;
public class RoundKnobButton extends RelativeLayout implements
OnGestureListener
{
public int eventValue=10;
//doctory starts
Paint p1,p2,p3;
RectF oval;
int width;
//doctory ends
private GestureDetector gestureDetector;
private float mAngleDown, mAngleUp;
private ImageView ivRotor;
private Bitmap bmpRotorOn, bmpRotorOff;
private boolean mState = false;
private int m_nWidth = 0, m_nHeight …Run Code Online (Sandbox Code Playgroud) 我是 C# 新手。我尝试使用 int 创建邮政服务。所有获取和发布服务都工作正常。
但是当我将参数传递给后期服务时,它始终为空。但创建一个类后它工作正常。我们可以直接将 int 传递给 service 还是我们必须为其创建一个模型类?
[System.Web.Http.HttpPost]
public IHttpActionResult GetUserByID(int id)
{
var user = userList.FirstOrDefault((p) => p.Id == id);
if (user== null)
{
return NotFound();
}
return Ok(user);
}
Run Code Online (Sandbox Code Playgroud)
但它总是发送 0 。但是当我创建一个类并将该 int 添加为属性时,它工作正常。
工作代码
[System.Web.Http.HttpPost]
public IHttpActionResult GetUserByID(data id)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
return Ok();
}
public class data
{
[Required]
public int id { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
编辑
我的标题准确吗?
android ×9
java ×3
c# ×1
callable ×1
firebase ×1
futuretask ×1
ondraw ×1
r.java-file ×1
view ×1
volume ×1
web-services ×1