这是我的 layout
________________ ___
| | ||
| Linear | ||
| Layout | ||
| | || nested scroll view
|______________| ||
|| || ||
|| || ||
|| Child || _||
||Recyclerview||
||____________||
|______________| -end
Run Code Online (Sandbox Code Playgroud)
如何使父级LinearLayout先滚动,到达末尾时,子级recyclerview应该滚动。
默认情况下RecyclerView,在父级开始滚动之前,子级首先滚动到结尾。
android android-scrollview android-recyclerview nestedscrollview
这是一个具有画廊背景的APP.使用REST我收到(Volley)JSON,其中包含有关地点和图片链接的信息.因为有大约60个地方,所以PICASSO的缓存形式是不够的.数据存储在DB中,所以我的想法是将图像插入到数据库中byte stream.它完成了,但不是很好,如下所示.代码里面AsyncTask.
@Override
protected Bitmap doInBackground(Void... params) {
try {
return Picasso.with(context)
.load(site.getImageURL())
.get();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Bitmap bitmap) {
super.onPostExecute(bitmap);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
try {
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
} catch (Exception e) {
e.printStackTrace();
}
site.setImageBytes(stream.toByteArray());
db.openForWrite();
db.updateSite(site.getId(), site);
db.close();
}
Run Code Online (Sandbox Code Playgroud)
我的问题是如何提高效率,你知道更好的方法吗?我试图让callbackPicasso将图像添加到数据库中onSuccess,但它需要将视图作为第一个参数.
也许有一种很好的方法可以将图像保存到SD卡,并用SD卡上的图像位置替换HTTP链接.
或者直接将图像缓存到光盘?
我试图使用SQLite android绑定在我的Android应用程序中有一个自定义加密的SQLite数据库.一切正常,我即将发布我的应用程序.我正在尝试使用ProGuard进行代码混淆和压缩,但似乎与SQLite android绑定无法正常工作.我发布的应用程序在启动时崩溃,因为它找不到SQLite使用的几个.so文件.我不确定保留这些库的正确ProGuard规则是什么.
现在我只添加了这个到我的ProGuard:
-keep class org.sqlite.**
Run Code Online (Sandbox Code Playgroud) 我想用proguard删除所有打印语句.是否与下面的代码相同,但是System.out.println()
-assumenosideeffects class android.util.Log {
public static *** d(...);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试将谷歌地图活动转换为在将在NavigationView中调用的片段内部工作.地图显示但是当我使用代码时getMapAsync
mFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);
mFragment.getMapAsync(this);
Run Code Online (Sandbox Code Playgroud)
我收到了一条错误消息
E/AndroidRuntime: FATAL EXCEPTION: main
E/AndroidRuntime: java.lang.NullPointerException
E/AndroidRuntime: at com.sample.samplemap.samplemapFragment.onCreate(samplemapFragment.java:32)
E/AndroidRuntime: at android.support.v4.app.Fragment.performCreate(Fragment.java:1942)
E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1040)
E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1259)
E/AndroidRuntime: at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1624)
E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517)
E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:725)
E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5306)
E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)
samplemapFragment.java
package com.sample.samplemap;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.gms.maps.GoogleMap;
import …Run Code Online (Sandbox Code Playgroud) 我正在开发一个应用程序,我在webview中从外部URL加载网页.加载页面需要花费很多时间才能加载,需要30秒到1分钟,所以请查看我的代码
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
public class WebActivity extends AppCompatActivity {
private WebView webView;
private ProgressBar progressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
webView = (WebView)findViewById(R.id.webView);
progressBar= (ProgressBar)findViewById(R.id.progressBar2);
String link = getIntent().getExtras().getString("webLink");
String title = getIntent().getExtras().getString("webTitle");
setTitle(title);
webView.setVisibility(View.GONE);
progressBar.setVisibility(View.VISIBLE);
Log.d("WEB", link);
webView.setWebViewClient(new MyBrowser());
webView.getSettings().setJavaScriptEnabled(true);
//webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
//webView.getSettings().setDomStorageEnabled(true);
//webView.getSettings().setAppCachePath(String.valueOf(getCacheDir()));
//webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.loadUrl(link);
}
@Override
public …Run Code Online (Sandbox Code Playgroud) 好的我在这里试图向用户发送有关无效附件的电子邮件.我正在收集上一个函数中的无效附件名称(字符串)列表,然后我尝试发送一封电子邮件,列出所有被视为无效的附件.不知道如何处理这种情况.我有以下示例
List<string> invalidType = new List<string>();
if (invalidType != null)
{
emailInvalidBody = new ItemBody
{
Content = " Expense attachements recieved with subject line [ "
+ email.Subject
+ " ] sent at [ "
+ email.DateTimeReceived.Value.DateTime.ToLocalTime()
+ " ] had the following invalid attachments ["
+ invalidType
+ "]. Please make sure all attachment's are images or PDF's.",
};
}
List<Recipient> emailInvalidRecipients = new List<Recipient>();
emailInvalidRecipients.Add(new Recipient
{
EmailAddress = new EmailAddress
{
Address = email.Sender.EmailAddress.Address
}
}); …Run Code Online (Sandbox Code Playgroud)