我知道StackOverflow中有很多类似的问题,但我的问题却略有不同.
我有嵌套的Fragments层次结构,如下面的结构:
Activity
|
|
AFragment
|
(ViewPager)
| |
| |
BFragment BFragment .....
|
(ViewPager)
| |
| |
CFragment CFragment ...
|
(ViewPager)
| |
| |
DFragment DFragment ...
Run Code Online (Sandbox Code Playgroud)
现在我想知道是否DFragment向用户显示?
我尝试了很多来自StackOverflow的解决方案,但无法取得成功.
我尝试的是:
我尝试setUserVisibleHint()但它返回上面的层次结构中的true多个DFragment,这是一个原因ViewPager
我也试过这些链接:link1,link2,link3等......但没有得到实际的解决方案.
等待帮助.谢谢.
UPDATE
适配器类
class ViewPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>();
public ViewPagerAdapter(FragmentManager manager) {
super(manager); …Run Code Online (Sandbox Code Playgroud) java android android-fragments android-view android-viewpager
我有一个ListView,我正在使用自定义适配器来显示数据.现在我想改变搜索文本字母颜色,如上面的屏幕截图.
这是代码 SearchView
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.actionbar_menu_item, menu);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
final SearchView searchView = (SearchView) menu.findItem(R.id.action_search)
.getActionView();
searchView.setSearchableInfo(searchManager
.getSearchableInfo(getComponentName()));
searchView.setOnQueryTextListener(this);
return super.onCreateOptionsMenu(menu);
}
public boolean onQueryTextChange(String newText) {
// this is adapter that will be filtered
if (TextUtils.isEmpty(newText)){
lvCustomList.clearTextFilter();
}
else{
lvCustomList.setFilterText(newText.toString());
}
return false;
}
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
我正在创建一个 Flutter 应用程序。
如果我在调试模式下运行这个应用程序,webview效果很好
但如果我在发布模式下运行此应用程序,它会显示空白屏幕。正在显示PlatformException
我尝试从 github issues 获取帮助,但找不到解决方案。
显现
<uses-permission android:name="android.permission.INTERNET"/>
Run Code Online (Sandbox Code Playgroud)
构建.gradle
minSdkVersion 20
targetSdkVersion 29
Run Code Online (Sandbox Code Playgroud)
pubspec.yaml
webview_flutter: ^1.0.7
Run Code Online (Sandbox Code Playgroud)
错误日志
E/flutter (16872): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: PlatformException(error, java.lang.IllegalStateException: Trying to create a platform view of unregistered type: plugins.flutter.io/webview
E/flutter (16872): at io.flutter.plugin.platform.j$a.g(Unknown Source:229)
E/flutter (16872): at io.flutter.embedding.engine.i.j$a.b(Unknown Source:152)
E/flutter (16872): at io.flutter.embedding.engine.i.j$a.j(Unknown Source:144)
E/flutter (16872): at e.a.c.a.j$a.a(Unknown Source:17)
E/flutter (16872): at io.flutter.embedding.engine.e.b.d(Unknown Source:57)
E/flutter (16872): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(Unknown Source:4)
E/flutter (16872): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (16872): at android.os.MessageQueue.next(MessageQueue.java:335) …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用更安全的方式编辑用户的共享首选项集EncryptedSharedPreferences
private fun provideSecureSharedPreference(context: Context): SharedPreferences {
val masterKey = MasterKey.Builder(context).setKeyScheme(MasterKey.KeyScheme.AES256_GCM).build()
return EncryptedSharedPreferences.create(
context, "secret_shared_prefs", masterKey, EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
)
}
Run Code Online (Sandbox Code Playgroud)
当我使用时它运行良好minifyEnabled false
现在我正在尝试通过执行以下操作来混淆代码minifyEnabled true
为了避免其他错误,现在我只将这些行放入我的proguard-rules.pro文件中
-dontobfuscate
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*,!code/allocation/variable
Run Code Online (Sandbox Code Playgroud)
但问题是当我设置时minifyEnable true我得到
java.io.FileNotFoundException: can't read keyset; the pref value __androidx_security_crypto_encrypted_prefs_key_keyset__ does not exist
Run Code Online (Sandbox Code Playgroud)
我尝试从 Stackoverflow 和其他渠道搜索旧帖子,但找不到解决方案。寻求帮助谢谢。
我在Android上新的请帮我自动隐藏滚动列表视图这里是我的代码但无法得到正确的解决方案
xml文件:
<ListView
android:id="@+id/offline_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#dde1e3"
android:clickable="true"
android:focusable="true"
>
</ListView>
Run Code Online (Sandbox Code Playgroud)
码:
lvCustomList.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
// TODO Auto-generated method stub
if(!hasFocus)
hideKeyboard(v);
}
private void hideKeyboard(View view) {
// TODO Auto-generated method stub
InputMethodManager inputMethodManger = (InputMethodManager)getSystemService(Activity
.INPUT_METHOD_SERVICE);
inputMethodManger.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
});
Run Code Online (Sandbox Code Playgroud) 我最近使用依赖项更新了播放服务
compile 'com.google.android.gms:play-services:7.5.0'
我的应用程序图标启动器已进入,@mipmap/ic_launcher"但这显示错误AndroidManifest.xml.我应该再次将此图标放入其中drawable吗?
帮我找出解决方案.
更新:这是来自Android工作室的消息
Error:(17, 9) Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@icon value=(@mipmap/ic_launcher) from AndroidManifest.xml:17:9
is also present at com.pnikosis:materialish-progress:1.0:13:9 value=(@drawable/ic_launcher)
Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:14:5 to override
Error:(17, 9) Attribute application@icon value=(@mipmap/ic_launcher) from AndroidManifest.xml:17:9
D:\3cworkspace\PeakPerformance\app\src\main\AndroidManifest.xml
Run Code Online (Sandbox Code Playgroud) 我想在其中设置YouTube视频ViewPager.为此我设置FrameLayout了适配器,我在其中设置了YoutubeVideoFragment,如下所示:
我的ViewPager适配器:
import android.app.Activity;
import android.app.FragmentTransaction;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.List;
import np.com.test.R;
import np.com.test.fragment.YoutubeVideoFragment;
/**
* Created by Vikash on 8/18/2015.
*/
public class TutorialVideoAdapter extends PagerAdapter {
private List<String> mList;
private Activity mActivity;
public TutorialVideoAdapter(Activity activity, List<String> list) {
mActivity = activity;
mList = list;
}
@Override
public int getCount() {
return mList.size();
}
@Override
public boolean isViewFromObject(View view, Object object) {
return …Run Code Online (Sandbox Code Playgroud) 我正在使用 aViewPager来显示片段。当我多次滑动它时,它会出现以下错误:
E/libc++abi: terminating with uncaught exception of type std::bad_alloc: std::bad_alloc
--------- beginning of crash
A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 6900
Run Code Online (Sandbox Code Playgroud)
我正在显示和缓存图像(使用这个)以及我正在使用TextView用来在Fragment.
我试图从其他链接获得帮助,但未能成功。
我试图使用下面的代码保存文本文件
try {
FileOutputStream fos = new FileOutputStream(TXT_FILE_NAME, true);
FileWriter fWriter;
try {
fWriter = new FileWriter(fos.getFD());
fWriter.write(binding.tvExtractedResult.getText().toString());
fWriter.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
fos.getFD().sync();
fos.close();
Toast.makeText(this, "File Saved Successfully", Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
Toast.makeText(this, "Error while saving file", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
但问题是此代码不适用于 Android Q。在此之后,我尝试搜索解决方案并执行此操作
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
ContentValues myContentValues = new ContentValues();
myContentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, TXT_FILE_NAME);
String myFolder = "Download/MY_PROJECT";
myContentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, myFolder);
myContentValues.put(MediaStore.MediaColumns.MIME_TYPE, "text/plain");
myContentValues.put(MediaStore.MediaColumns.IS_PENDING, 1);
Uri extVolumeUri = MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL);
ContentResolver contentResolver …Run Code Online (Sandbox Code Playgroud) 我有一个POST方法API,它在Postman中提供了200个响应代码,但在使用Volley甚至在Retrofit2中调用api时却没有.
这是邮差截图:
这是我为Volley库代码所做的:
final String url = "http://xxxxxxxx.com/api/mobile/user/post/";
StringRequest stringReq = new StringRequest(Request.Method.POST, url,
new com.android.volley.Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.e("onResponse ===", response + " " );
}
},
new com.android.volley.Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e("onErrorResponse ===", error + " " );
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
params.put("Authorization", "xxxxxxxxxxxxx");
return params;
}
@Override
public …Run Code Online (Sandbox Code Playgroud) 我开发了一个android应用程序.启动应用程序后,它显示启动画面和登录,它可以在模拟器和真实 设备上运行,但是当我按设备上的跳过选项时应用程序崩溃但不在模拟器中.这是logcat的错误:
07-11 12:48:59.735: D/skia(4382): jpeg_decoder mode 1, config 6, w 640, h 1136, sample
1, bsLength 142a5!!
07-11 12:49:01.589: D/libc-netbsd(4382): getaddrinfo: autolife.com.np get result from proxy >>
07-11 12:49:02.126: D/skia(4382): jpeg_decoder mode 1, config 6, w 640, h 1136, sample 1, bsLength f1ae!!
07-11 12:49:08.694: W/dalvikvm(4382): VFY: unable to resolve virtual method 62: Landroid/app/ActionBar;.setHomeAsUpIndicator (I)V
07-11 12:49:08.868: E/AndroidRuntime(4382): FATAL EXCEPTION: main
07-11 12:49:08.868: E/AndroidRuntime(4382): java.lang.NoSuchMethodError: android.app.ActionBar.setHomeAsUpIndicator
07-11 12:49:08.868: E/AndroidRuntime(4382): at np.com.autolife.activity.BaseActivity.onCreate(BaseActivity.java:41) …Run Code Online (Sandbox Code Playgroud) 我正在使用Android Beacon Library检测信标.
根据其他Stackoverflow问题,下面的答案是解决方案
beaconManager.setBackgroundScanPeriod(60000l);
beaconManager.setBackgroundBetweenScanPeriod(60000l);
beaconManager.updateScanPeriods();
Run Code Online (Sandbox Code Playgroud)
但就我而言,它不起作用.我无法对扫描周期进行变化.
这是代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
beaconManager = BeaconManager.getInstanceForApplication(this);
beaconManager.getBeaconParsers().add(new BeaconParser()
.setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
beaconManager.bind(this);
}
@Override
public void onBeaconServiceConnect() {
try {
beaconManager.setBackgroundScanPeriod(60000l);
beaconManager.setBackgroundBetweenScanPeriod(60000l);
beaconManager.updateScanPeriods();
beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId",
Identifier.parse(Config.PROXIMITY_UUID), null, null));
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
if (beacons.size() > 0) {
Log.i(TAG, "minor:"+ beacons.iterator().next().getId3());
}
}
});
} catch (RemoteException e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个LinearLayout与水平方向,我在其中添加了多种TextView使用XML代码这个布局中,我不想改变它的方向.下面是结果:

如何在不改变Linearlayout方向的情况下在上述文本下方显示剩余文本.提前致谢.