我正在研究Horizontal RecyclerView的简单演示.
我想显示滚动条和recyclerview.所以,我已经加入android:scrollbars="horizontal"和android:scrollbarSize="5dp"XML格式.
我能够获得滚动条,但它显示在底部.我想要实现的是将它显示在Top上.我发现了一些像这样的问题,但它们都不适用于水平RecyclerView +顶部滚动条.
这是我到目前为止尝试过的代码:
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:isScrollContainer="false"
android:orientation="horizontal"
android:scrollbars="horizontal"
android:scrollbarSize="5dp"
android:visibility="visible" />
Run Code Online (Sandbox Code Playgroud)
谢谢!
查询描述:比方说,我有一个数据库表,它以加密形式存储所有用户的数据。我有一个管理员可以搜索用户数据的功能。现在的问题是,管理员将在文本框中输入普通文本,我必须根据管理员的输入过滤用户列表(在每次文本更改时)。所以与此同时,我有一堆加密形式的数据,我必须根据管理员输入的普通文本对其进行过滤。
到目前为止,我提出的解决方案是,我首先解密所有数据,然后应用过滤器。但我很想知道,如果我的数据库中有数百万条记录,那么当前的方式似乎毫无用处且效率低下。
任何人都可以帮助我以最有效的方式搜索加密数据吗?
任何帮助将不胜感激!
谢谢。
查询描述:我正在使用带有透明主题的自定义进度对话框。这工作正常。我面临的问题是,当我的键盘打开时,如果我显示自定义进度对话框,它会强制关闭我的键盘。但是,如果我使用默认的 Progress Dialog 那么它就可以正常工作。
:如您所见,即使出现进度对话框,键盘仍然存在。我想在自定义进度对话框中实现相同的功能。
:如您所见,显示对话框时键盘会消失。感觉很乏味,每次用户都要打开键盘。
这是我的代码:
public class CustomProgressDialog extends Dialog {
private ImageView imageView;
private Context mContext;
public CustomProgressDialog(Context context) {
super(context, R.style.DialogTheme);
mContext = context;
getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
WindowManager.LayoutParams wlmp = getWindow().getAttributes();
wlmp.gravity = Gravity.CENTER_HORIZONTAL;
getWindow().setAttributes(wlmp);
setTitle(null);
setCancelable(true);
//setOnCancelListener(null);
LinearLayout layout = new LinearLayout(context);
layout.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(200, 200);
imageView = new ImageView(context);
imageView.setBackgroundResource(R.drawable.custom_dialog);
layout.addView(imageView, params);
addContentView(layout, params);
}
@Override
public void show() {
super.show();
AnimationDrawable frameAnimation = (AnimationDrawable) imageView.getBackground();
frameAnimation.start();
} …Run Code Online (Sandbox Code Playgroud) 我已经在PhoneGap中开发了一个应用程序,它通过地理定位API跟踪您的行进路线,我通过navigator.geolocation.getCurrentPosition(onSuccess, onError);定期间隔后通过获取位置来获取设备的当前位置并更新折线navigator.geolocation.watchPosition(function(position)
但是现在问题是它不能在后台工作,即(当我打开另一个应用程序并且它开始在后台运行时)它不会更新折线意味着不会触发此navigator.geolocation.watchPosition(function(position)功能所以我尝试通过Cordova-plugin-background-mode此插件运行应用程序,它开始在后台运行应用程序并再次触发该navigator.geolocation.watchPosition(function(position)函数意味着这不是必需的,即(没有必要安装插件以在后台模式下运行应用程序).所以请帮我解决在后台模式下获取位置的问题.如果我使用这个Cordova-plugin-mauron85-background-geolocation插件,我可以获得一个位置,因为我通过观察位置?如果应用程序在前台运行该怎么办?我是否必须使用该watchPosition功能或其他东西?
当我查看 Android 教程和/或 Android 官方文档时,似乎有多种不同的方式来查询位置。我很困惑,因为我不确定哪种方法是正确的方法或者文档是否已过时。
例如,
1)GoogleApiClient:这样就使用了Google API客户端
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
Run Code Online (Sandbox Code Playgroud)
然后它查询像这样的位置
LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
Run Code Online (Sandbox Code Playgroud)
2)位置管理器:这种方式使用位置管理器
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
Location lastKnownLocation = locationManager.getLastKnownLocation(locationProvider);
Run Code Online (Sandbox Code Playgroud)
3)FusedLocationApi(第二种风格):
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
mFusedLocationClient.getLastLocation()
.addOnSuccessListener(this, new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
// Got last known location. In some rare situations, this can be null.
if (location != null) {
// Logic to handle location object
}
}
});
Run Code Online (Sandbox Code Playgroud)
我们应该使用哪种方式?
我正在研究用户可以搜索数据的项目。为此,我已经实施了AutoCompleteTextView.
autoComplete.setAdapter(new ArrayAdapter<String>(CheckRiskActivity.this,
R.layout.auto_text_row, druglist));
autoComplete.setThreshold(1);
//druglist is my arraylist
Run Code Online (Sandbox Code Playgroud)
文本更改侦听器如下:
autoComplete.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
// here I want to get the size of filtered array list every time when the user adds any character.
}
@Override
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
}
});
Run Code Online (Sandbox Code Playgroud)
说明:如果我的初始数组大小为 100 并且用户键入“a”,那么我想获取过滤数组的大小。
注意:我已经尝试过,autoComplete.getAdapter().getCount();但它在添加一个字符后给出了实际结果。
android filtering arraylist autocompletetextview android-adapter
这是我的布局的一部分:
<com.rey.material.widget.EditText
android:id="@+id/tagEditorSettings"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginStart="10dp"
android:layout_toEndOf="@+id/circularProgressbar"
android:hint="@string/tag_name_tag_settings"
android:inputType="text"
android:textSize="18sp"
app:et_dividerColor="@color/my_primary"
app:et_dividerHeight="1dp"
app:et_inputId="@+id/name_input"
app:et_labelEnable="true"
app:et_labelTextSize="14sp"
app:et_supportLines="1" />
Run Code Online (Sandbox Code Playgroud)
和我的测试代码:
onView(withId(R.id.tagEditorSettings))
.perform(click()).perform(clearText());
Run Code Online (Sandbox Code Playgroud)
当我尝试运行它时,我收到这样的错误:
引起:java.lang.RuntimeException:由于目标视图不匹配以下一项或多项约束,将不会执行操作:(在屏幕上显示给用户并且可从类:class android.widget.EditText )
据我所知,问题出在“可从类中分配:类 android.widget.EditText”,但有人可以请教,我如何修复它并在我的情况下使用?
我要求我必须在android中截取当前窗口的截图.这是我正在使用的代码,
View rootView = getWindow().getDecorView().findViewById(android.R.id.content);
View screenView = rootView.getRootView();
screenView.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(screenView.getDrawingCache());
screenView.setDrawingCacheEnabled(false);
Run Code Online (Sandbox Code Playgroud)
通过使用这个我可以得到应用程序屏幕截图,但状态栏内容丢失(蓝牙图标,电池状态等).如何以编程方式截取当前Android手机窗口的屏幕截图(包括状态栏内容)?可能吗?
android ×7
arraylist ×1
cordova ×1
database ×1
dialog ×1
encryption ×1
filter ×1
filtering ×1
geolocation ×1
java ×1
location ×1
mysql ×1
php ×1
screenshot ×1