我有一个Android应用程序来保存登录详细信息,如用户名和密码通过它SharedPreferences工作正常,但我需要删除SharedPreferences我的应用程序卸载时使用的所有.怎么做?
SavePreferences("one ", "");
SavePreferences("two", "");
LoadPreferences();
private void SavePreferences(String key, String value){
sharedPreferences = getSharedPreferences("TEST", MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(key, value);
editor.commit();
}
private void LoadPreferences(){
sharedPreferences = getSharedPreferences("TEST", MODE_PRIVATE);
String strSavedMem1 = sharedPreferences.getString("MEM1", "");
String strSavedMem2 = sharedPreferences.getString("MEM2", "");
}
Run Code Online (Sandbox Code Playgroud)
我想SharedPreferences在我的应用程序卸载时删除它.
我试图禁用用户拖动BottomSheet.我想禁用的原因是两件事.1.它阻止ListView向下滚动,2.我不希望用户使用拖动但是使用按钮来解除BottomSheetView.这就是我所做的
bottomSheetBehavior = BottomSheetBehavior.from(bottomAnc);
bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (newState == BottomSheetBehavior.STATE_EXPANDED) {
//Log.e("BottomSheet", "Expanded");
} else if (newState == BottomSheetBehavior.STATE_COLLAPSED) {
//Log.e("BottomSheet", "Collapsed");
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
// React to dragging events
bottomSheet.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = MotionEventCompat.getActionMasked(event);
switch (action) {
case MotionEvent.ACTION_DOWN:
return false;
default:
return true;
} …Run Code Online (Sandbox Code Playgroud) 我们有一个应用程序,可以使用Google Play服务位置API捕获用户的位置,用于Geotag land等每笔交易,下订单等.
从移动设备捕获这些位置后,我们会将其同步到服务器并在Web仪表板中显示.
我们注意到在少数情况下,在几秒钟内捕获的交易具有不同距离的位置结果.
示例:
用户的位置将在
Mandsaur,Madhya Pradesh,印度,亚洲
(纬度 - 24.057291,经度 - 75.0970672,捕获日期 - 2017-01-04 09:19:48).
但随后的交易将有 6772公里外的
巴黎
(纬度 - 48.8581074,经度 - 2.3525187,截获日期 - 2017-01-04 09:20:01)
有时取指令错误陈述的印度象用户从古吉拉特然后位置比哈尔邦,马哈拉施特拉邦,科威特的获取(从印度)它真的头疼印度开发商
因为这发生在没有用户干扰且用户设备中没有安装模拟位置应用程序的情况下.
任何人都可以解释为什么会这样,我们怎么能避免这些情况?
注意:
这些交易位置通常在开启GPS的情况下捕获,并设置为高精度模式
我正在尝试添加运行时权限android(6.0.1)API 23,如果我使用SDK版本(min和目标版本都是23)它就好了,如下所示,
<uses-sdk
android:minSdkVersion="23"
android:targetSdkVersion="23" />
Run Code Online (Sandbox Code Playgroud)
如果我改变android:minSdkVersion(少于23)
例如:
我收到以下错误:
调用需要API级别23(当前最小值为14):android.app.Activity#requestPermissions,checkSelfPermission
对于以下2种方法,
1)requestPermissions(permissionsList.toArray(new String[permissionsList.size()]),REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS)
2)checkSelfPermission(permission)
Run Code Online (Sandbox Code Playgroud)
我试过了ActivityCompat.checkSelfPermission(),ContextCompat.checkSelfPermission()两个都没有用.
我遗失的东西无法理解..
android android-permissions android-support-library android-6.0-marshmallow
我正在尝试隐藏我的工具栏,当我滚动我的文本和图像与内容,这里我使用scrollView获取滚动内容时,当我滚动内容如何隐藏工具栏请任何人告诉我如何获得
这是我的XMl代码
content_main.XML
<android.support.v4.widget.NestedScrollView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:paddingTop="?android:attr/actionBarSize"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:id="@+id/textone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="23dp"
android:textStyle="bold"
android:text="hello world jheds sdjhs jds sjbs skjs ksjs kksjs ksj sdd dskd js sk "/>
<ImageView
android:id="@+id/imge"
android:layout_width="match_parent"
android:layout_height="250dp"
android:src="@drawable/imag_bg"/>
<TextView
android:id="@+id/texttwo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="Pretty good, the Toolbar is moving along with the list and getting back just as we expect it to. This is thanks to the restrictions that we put …Run Code Online (Sandbox Code Playgroud) android android-support-library android-toolbar android-support-design
这不是我的应用程序,这是将其源代码放在github上的北欧应用程序,我试图在我的机器上运行soutce.但我一直有这个错误:
03-07 07:12:13.641 12622-12622/com.noxel.apppaneladmintry2 E/AndroidRuntime? FATAL EXCEPTION: main
Process: com.noxel.apppaneladmintry2, PID: 12622
java.lang.IllegalStateException: View can not be anchored to the the parent CoordinatorLayout
at android.support.design.widget.CoordinatorLayout$LayoutParams.resolveAnchorView(CoordinatorLayout.java:2522)
at android.support.design.widget.CoordinatorLayout$LayoutParams.findAnchorView(CoordinatorLayout.java:2491)
at android.support.design.widget.CoordinatorLayout.prepareChildren(CoordinatorLayout.java:619)
at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:670)
at android.view.View.measure(View.java:17442)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
at android.view.View.measure(View.java:17442)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
at android.view.View.measure(View.java:17442)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
at android.view.View.measure(View.java:17442)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
at android.view.View.measure(View.java:17442)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2560)
at android.view.View.measure(View.java:17442)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2001)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1166)
at …Run Code Online (Sandbox Code Playgroud) user-interface android floating android-support-library android-support-design
我想在图像的背景中的半圆形进度条.就像下图一样.

我试图用画布画画,但无法获得成功.我也厌倦了一些自定义进度条库但结果是一样的.
有什么建议.
寻找一次性开发并用于每个屏幕尺寸.
我想制作如下图像的视图...轻扫以在ANDROID中选择.

我在github上找到了一个库:
https://github.com/kikoso/Swipeable-Cards
http://grishma102.blogspot.in/2014/04/tinder-app-like-control-with-animation.html
但是在这个lib中没有选项可以在CARD 上显示LIKE或NOPE,就像在上面的图像中显示一样
任何人都可以帮助我如何在这个库中添加这些未来.
我已经创建了onTouchListener中的视图组类
我试图得到onClickListener内onTouchListener
我的问题是,当我在左,右角触摸点击事件前一段时间它的旋转视图中点击是工作,所以我如何阻止它时,点击是工作的另一个问题是,当动画停止其也火单击事件
任何人帮我改进下面的代码?
this.imageContainerLayout.setOnTouchListener(new OnTouchListener() {
private long startClickTime;
private float x1;
private float y1;
private float x2;
private float y2;
private float _dx;
private float _dy;
@Override
public boolean onTouch(View v, MotionEvent event) {
x_cord = (int) event.getRawX();
y_cord = (int) event.getRawY();
Log.e("start x_cord-->" + x_cord, "y_cord--->" + y_cord);
boolean defaultResult = v.onTouchEvent(event);
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
x = (int) …Run Code Online (Sandbox Code Playgroud) 我有一个操作栏,下面有两个标签.它在大多数智能手机中看起来都不错,但是在平板电脑或nexus 4中,标签不会伸展以占据屏幕的整个宽度.
这是截图(在Nexus 4上拍摄):

可以看出,标签的每一侧有两个黑条.我正在使用动作栏sherlock.有没有办法让标签占据全宽?某种我可以覆盖的ABS属性?
我已经完成了我的应用程序,现在需要处理适应多种屏幕尺寸.
在这一点上,似乎我唯一的选择是做以下事情:
有一个单独的xml布局:小尺寸,普通尺寸,大尺寸和X大屏幕尺寸.在其中有一个单独的xml布局:ldpi,mdpi,hdpi和xhdpi在纵向和横向之间有一个单独的xml布局.
对于一个活动,总共有32个布局.
我只是想知道是否有更好的方法来执行此操作,因为这将非常耗时,但是如果需要支持所有可能的设备,我不介意.
我做了一些阅读,人们说使用线性布局并使用重力,因为它是一个百分比,所以它在所有屏幕上看起来都一样.或者我可以使用RelativeLayout并使用"AlignAbove或Below"等.
然而,我的主要问题是尺寸错误,而元素的位置似乎通常在正确的位置.
有一种被广泛接受的方式吗?
我真的只是在寻找普通开发人员处理所有屏幕尺寸的"主流"方式.