我升级到最新的sdk版本23.现在我的一些代码不再工作了.这是我以前获得json的课程:
public class Spots_tab1_json {
static String response = null;
public final static int GET = 1;
public final static int POST = 2;
public Spots_tab1_json() {
}
public String makeServiceCall(String url, int method) {
return this.makeServiceCall(url, method, null);
}
public String makeServiceCall(String url, int method,
List<NameValuePair> params) {
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpEntity httpEntity = null;
HttpResponse httpResponse = null;
if (method == POST) {
HttpPost httpPost = new HttpPost(url);
httpPost.addHeader("Cache-Control", "no-cache");
if (params != null) …Run Code Online (Sandbox Code Playgroud) 我想为我的应用程序使用proguard,我启用它但是当我想生成apk文件时,它给了我这个错误:
Information:Gradle tasks [:app:assembleRelease]
:app:preBuild UP-TO-DATE
:app:preReleaseBuild UP-TO-DATE
:app:checkReleaseManifest
:app:preDebugBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72300Library UP-TO-DATE
:app:prepareComAndroidSupportCardviewV72300Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2300Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72300Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42300Library UP-TO-DATE
:app:prepareJpWasabeefRecyclerviewAnimators122Library UP-TO-DATE
:app:prepareReleaseDependencies
:app:compileReleaseAidl UP-TO-DATE
:app:compileReleaseRenderscript UP-TO-DATE
:app:generateReleaseBuildConfig UP-TO-DATE
:app:generateReleaseAssets UP-TO-DATE
:app:mergeReleaseAssets UP-TO-DATE
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources UP-TO-DATE
:app:mergeReleaseResources UP-TO-DATE
:app:processReleaseManifest UP-TO-DATE
:app:processReleaseResources UP-TO-DATE
:app:generateReleaseSources UP-TO-DATE
:app:processReleaseJavaRes UP-TO-DATE
:app:compileReleaseJava UP-TO-DATE
:app:compileReleaseNdk UP-TO-DATE
:app:compileReleaseSources UP-TO-DATE
:app:lintVitalRelease
:app:proguardRelease
Note: there were 7 duplicate class definitions.
(http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
Warning:library class org.apache.http.conn.scheme.LayeredSocketFactory extends or implements program class org.apache.http.conn.scheme.SocketFactory
Warning:org.acra.ErrorReporter: can't find referenced method 'void setLatestEventInfo(android.content.Context,java.lang.CharSequence,java.lang.CharSequence,android.app.PendingIntent)' …Run Code Online (Sandbox Code Playgroud) 我已经下载了最新的appcompact版本.这是我的傻瓜:
apply plugin: 'com.android.application'
android {
compileSdkVersion 16
buildToolsVersion '23.0.0'
defaultConfig {
applicationId "com.example.navid.recycleview"
minSdkVersion 8
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
}
Run Code Online (Sandbox Code Playgroud)
在sdk经理中,我已经为api23和21下载了sdk平台和google apis.
当我重建项目时,会打开v21\values-v21.xml,这个文件中有很多错误:
F:\AndroidStudioProjects\recycleView\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.0.0\res\values-v17\values-v17.xml
Error:(6, 21) No resource found that matches the given name: attr 'android:textAlignment'.
Error:(10, 21) No resource found that matches the given name: attr 'android:paddingEnd'.
Error:(10, 21) No resource found that matches the given name: …Run Code Online (Sandbox Code Playgroud) 我正在使用回收视图,我通过 json 从网络获取数据并使用适配器将项目添加到我的回收视图。我想在用户到达回收视图末尾时获取新项目。
我使用 GridLayoutManager 作为我的回收视图。这是代码:
int pastVisiblesItems, visibleItemCount, totalItemCount;
GridLayoutManager mLayoutManager;
private boolean loading = true;
recycle=(RecyclerView)findViewById(R.id.recycle);
mLayoutManager = new GridLayoutManager(this, 3);
// (Context context, int spanCount)
recycle.setLayoutManager(mLayoutManager);
recycle.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
visibleItemCount = mLayoutManager.getChildCount();
totalItemCount = mLayoutManager.getItemCount();
pastVisiblesItems = mLayoutManager.findFirstVisibleItemPosition();
if (loadmore) {
if ((visibleItemCount + pastVisiblesItems) >= totalItemCount) {
page = page + 1;
Toast.makeText(Cats.this, "test", Toast.LENGTH_SHORT);
}
}
}
});
Run Code Online (Sandbox Code Playgroud)
我到了 recycleview 的结尾,但它没有显示任何 toast,所以我认为它不明白我到达了 recycle view 的结尾。 …
我已经将图像设置为linearlayout的背景。这是代码:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/mainbg"
android:orientation="vertical"
android:padding="5dp"
>
Run Code Online (Sandbox Code Playgroud)
问题是,图像的宽度约为2000像素,我不想缩小与屏幕的比例,我只想显示与背景一样多的东西,而不是拉长它。
我该怎么办?
谢谢
我想把我得到的每一双都弄圆.我搜索并找到了Math.ceil,但它没有像我预期的那样工作.例如 :
Log.v("this", "" + Math.ceil(300 / 1000));-->returns 0 - expected 1
Log.v("this",""+Math.ceil(100 / 1000));-->returns 0 - expected 1
Log.v("this",""+Math.ceil(50 / 1000));-->returns 0 - expected 1
Log.v("this",""+Math.ceil(700 / 1000));-->returns 0 - expected 1
Log.v("this",""+Math.ceil(1000 / 1000)); -->this is ok
Log.v("this",""+Math.ceil(1020 / 1000));-->returns 1 - expected 2
Run Code Online (Sandbox Code Playgroud)
我该怎么办 ?