在我的活动中,我正在通过主要活动调用第二个活动startActivityForResult
.在我的第二个活动中,有一些方法可以完成此活动(可能没有结果),但是,只有其中一个返回结果.
例如,从主要活动我称之为第二个.在这项活动中,我正在检查手机的某些功能,例如是否有相机.如果它没有,那么我将关闭此活动.此外,在准备期间MediaRecorder
或MediaPlayer
如果出现问题,我将关闭此活动.
如果其设备有摄像头并完全录制,则在用户点击完成按钮后录制视频后,我会将结果(录制视频的地址)发送回主要活动.
如何检查主要活动的结果?
android android-intent android-activity startactivityforresult
我有一个TextView
我想限制它的字符.实际上,我可以做到这一点,但我正在寻找的是如何在字符串的末尾添加三个点(...).这一个显示文本已经继续.这是我的XML,但没有点,虽然它限制了我的文本.
<TextView
android:id = "@+id/tvFixture"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:layout_toLeftOf = "@id/ivFixture_Guest"
android:text = "@string/test_06"
android:lines = "1"
android:ems = "3"
android:gravity = "right"
style = "@style/simpletopic.black"
android:ellipsize="end"/>
Run Code Online (Sandbox Code Playgroud) 在我的项目中,我有一个EditText
.我想计算中的字符数EditText
,并在数字中显示该数字TextView
.我写了以下代码,它工作正常.但是,我的问题是当我点击Backspace它计数时,但我需要减少数量.我怎么考虑Backspace?
tv = (TextView)findViewById(R.id.charCounts);
textMessage = (EditText)findViewById(R.id.textMessage);
textMessage.addTextChangedListener(new TextWatcher(){
public void afterTextChanged(Editable s) {
i++;
tv.setText(String.valueOf(i) + " / " + String.valueOf(charCounts));
}
public void beforeTextChanged(CharSequence s, int start, int count, int after){}
public void onTextChanged(CharSequence s, int start, int before, int count){}
});
Run Code Online (Sandbox Code Playgroud) 我通过此命令将本地主服务器重置为提交:
git reset --hard e3f1e37
Run Code Online (Sandbox Code Playgroud)
当我输入$ git status
命令时,终端说:
# On branch master
# Your branch is behind 'origin/master' by 7 commits, and can be fast-forwarded.
# (use "git pull" to update your local branch)
#
nothing to commit, working directory clean
Run Code Online (Sandbox Code Playgroud)
由于我也要重置原点/标题,我结帐到origin/master:
$ git checkout origin/master
Note: checking out 'origin/master'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without …
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我有一个EditText.我希望用户只具有读访问权限而不是写访问权限.在我设置的代码中android:enabled="false"
.虽然EditText的背景变为黑暗,但当我点击它时,键盘弹出,我可以更改文本.
我该怎么办?谢谢
每次应用程序启动时,我将当前时间存储在数据库中.
Calendar c = Calendar.getInstance();
String str = c.getTime().toString();
Log.i("Current time", str);
Run Code Online (Sandbox Code Playgroud)
在数据库方面,我将当前时间存储为字符串(如上面的代码所示).因此,当我从数据库加载它时,我需要将其强制转换为Date对象.我看到了一些样本,他们都使用了"DateFormat".但我的格式与日期格式完全相同.所以,我认为没有必要使用"DateFormat".我对吗?
无论如何直接将此String转换为Date对象?我想将此存储时间与当前时间进行比较.
谢谢
======> 更新
谢谢亲爱的伙计们.我使用以下代码:
private boolean isPackageExpired(String date){
boolean isExpired=false;
Date expiredDate = stringToDate(date, "EEE MMM d HH:mm:ss zz yyyy");
if (new Date().after(expiredDate)) isExpired=true;
return isExpired;
}
private Date stringToDate(String aDate,String aFormat) {
if(aDate==null) return null;
ParsePosition pos = new ParsePosition(0);
SimpleDateFormat simpledateformat = new SimpleDateFormat(aFormat);
Date stringDate = simpledateformat.parse(aDate, pos);
return stringDate;
}
Run Code Online (Sandbox Code Playgroud) 在我的活动中,我有一些评级栏.但这个酒吧的大小是如此之大!我怎样才能让它变小?
编辑
感谢Gabriel Negut,我用以下风格做到了:
<RatingBar
style = "?android:attr/ratingBarStyleSmall"
android:numStars = "5"
android:rating = "4" />
Run Code Online (Sandbox Code Playgroud)
现在,尺寸减小但星数和等级不生效!为什么?我有7颗星,其中6颗被选中.
基于我的android密钥库,我创建了一些应用程序.现在,我想更新我的一个程序,但我丢失了我的密钥库.我可以生成另一个并更新我的应用程序吗?
谢谢
在我的应用程序中,我需要阅读Qr代码.我在网上搜索并找到了Zing代码但是很多开发人员使用它时遇到了问题,而且它似乎有问题!
如果我假设我的客户在他们的设备上安装了qr阅读器,我如何使用这些应用程序并通过隐式意图调用它们?
如果用户没有任何qr阅读器,应用程序会发生什么?如果它崩溃,我可以要求用户下载例如QrDroid,然后使用它吗?
我的片段中有地图视图.我需要刷新地图并根据条件添加不同的标记.因此,我应该在添加新标记之前从地图中删除最后一个标记.
实际上,几周前应用程序工作正常,突然发生了.我的代码是这样的:
private void displayData(final List<Venue> venueList) {
// Removes all markers, overlays, and polylines from the map.
googleMap.clear();
.
.
.
}
Run Code Online (Sandbox Code Playgroud)
上次它工作正常(在2013年I/O中由Android团队宣布新的Google Map API之前).但是,之后我调整了我的代码以使用这个新的API.现在,我不知道为什么这种方法googleMap.clear();
不起作用!
任何建议将不胜感激.谢谢
=======
更新
=======
完整代码:
private void displayData(final List<Venue> venueList) {
// Removes all markers, overlays, and polylines from the map.
googleMap.clear();
// Zoom in, animating the camera.
googleMap.animateCamera(CameraUpdateFactory.zoomTo(ZOOM_LEVEL), 2000, null);
// Add marker of user's position
MarkerOptions userIndicator = new MarkerOptions()
.position(new LatLng(lat, lng))
.title("You are here")
.snippet("lat:" + lat + …
Run Code Online (Sandbox Code Playgroud)