小编Mic*_*sin的帖子

为什么警告:无法找到可选库:org.apache.http.legacy发生?

我的gradle文件:

apply plugin: 'com.android.application' 

android { 
  useLibrary 'org.apache.http.legacy' 
  compileSdkVersion 23 
  buildToolsVersion "23.0.0" 

  defaultConfig { 
    applicationId "com.skripsi.irwanto.paud" 
    minSdkVersion 15 
    targetSdkVersion 23 
    versionCode 1 
    versionName "1.0" 
  } 

  buildTypes { 
    release { 
      minifyEnabled false 
      proguardFiles getDefaultProauardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
  } 
} 
dependencies { 
 compile fileTree(include: ['*.jar'], dir: 'libs') 
 testCompile 'junit:junit:4.12' 
 compile 'com.android.support:appcompat-v7:23.1.11 
} 
Run Code Online (Sandbox Code Playgroud)

我明白了 Warning:Unable to find optional library: org.apache.http.legacy

android apache-commons-httpclient

30
推荐指数
2
解决办法
4万
查看次数

如何从Java隐藏Kotlin的lateinit var支持字段?

在Kotlin,假设,我有课:

class MyKotlinClass {
    lateinit var field: String
}
Run Code Online (Sandbox Code Playgroud)

根据文件:

延迟初始化的属性也作为字段公开.该字段的可见性将与lateinit属性设置器的可见性相同.

我可以在java代码中使用myKotlinClass.fieldmyKotlinClass.getField().我想禁用字段访问,只保留通过gettersetter访问.

我怎样才能实现这一目标并保持延迟修饰?

java kotlin kotlin-lateinit

10
推荐指数
1
解决办法
803
查看次数

HttpURLConnection请求被命中两次到服务器下载文件

以下是我从android下载文件的android代码.

private String executeMultipart_download(String uri, String filepath)
            throws SocketTimeoutException, IOException {
        int count;
        System.setProperty("http.keepAlive", "false");
        // uri="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcTzoeDGx78aM1InBnPLNb1209jyc2Ck0cRG9x113SalI9FsPiMXyrts4fdU";
        URL url = new URL(uri);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.connect();
        int lenghtOfFile = connection.getContentLength();
        Log.d("File Download", "Lenght of file: " + lenghtOfFile);

        InputStream input = new BufferedInputStream(url.openStream());
        OutputStream output = new FileOutputStream(filepath);
        byte data[] = new byte[1024];
        long total = 0;

        while ((count = input.read(data)) != -1) {
            total += count;
            publishProgress("" + (int) ((total * 100) / lenghtOfFile));
            output.write(data, 0, count); …
Run Code Online (Sandbox Code Playgroud)

java android httpurlconnection

5
推荐指数
1
解决办法
1254
查看次数

寻找正在运行的 android webview 上的下拉菜单

显示了框架 7 中的本机选择和智能选择选择器,但当我单击它们时,没有任何内容打开。这是我尝试过的一个示例,我可以看到下拉菜单,但是当我单击它时什么也没有发生:

<select name="car">   
  <option value="mercedes">Mercedes</option>
  <option value="bmw">BMW</option>
  <option value="volvo">Volvo</option>
  <option value="vw" selected="">Volkswagen</option>
  <option value="toyota">Toyota</option>
  <option value="cadillac">Cadillac</option>
  <option value="nissan">Nissan</option>
  <option value="mazda">Mazda</option>
  <option value="ford">Ford</option>
  <option value="chrysler">Chrysler</option>
  <option value="dodge">Dodge</option>
</select>
Run Code Online (Sandbox Code Playgroud)

有什么在 Android Web 视图上运行良好的下拉组件的建议吗?

android webview android-layout android-webview drop-down-menu

5
推荐指数
0
解决办法
560
查看次数

如何使用锚点从协调器布局移动视图?

假设我的布局类似于:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:id="@+id/bottomIcon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:src="@drawable/some_image"
        app:layout_anchor="@+id/bottomNavigation"
        app:layout_anchorGravity="top|center"/>

    <some.widget.SomeView
        android:id="@+id/bottomView"
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:layout_gravity="bottom"/>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

一切都很好,bottomIcon放在上面bottomView.当我尝试翻译bottomView一点时,一切仍然是好的,bottomIcon也被翻译了.

但是,当我尝试bottomView从屏幕上翻译下来时:

public void slideOut(View view) {
    view.animate()
        .translationY(500) //example constant
        .start();
}

//then somewhere call
slideOut(bottomView)
Run Code Online (Sandbox Code Playgroud)

然后bottomView移出屏幕bottomIcon,直到它达到CoordinatorLayout的下限.然后bottomIcon不要向下移动.

bottomIcon即使锚点离开屏幕,我怎样才能实现锚定视图()跟随其锚点('bottomView')?(解决方案越简单越优越好)

android android-animation android-coordinatorlayout

5
推荐指数
0
解决办法
437
查看次数

为什么Kotlin没有十进制进展?

最近我遇到了一个问题,通过十进制步骤迭代十进制数字,我很想知道,为什么Kotlin只有进步Int,Long而且Char.

我明白,可能会有一些带小数的警告.但仍然.我们只想要一个起始BigDecimal编号,结束BigDecimal编号,然后用BigDecimal步骤迭代它们.

问:那么,为什么整数不存在任何进展?谢谢.

PS:这是一个可能实现的示例代码(我为Int采用了源代码并进行了调整BigDecimal):

/**
 * Returns a progression that goes over the same range with the given step.
 */
public infix fun BigDecimalProgression.step(step: BigDecimal): BigDecimalProgression {
    if (step <= java.math.BigDecimal.ZERO) throw IllegalArgumentException("Step must be positive, was: $step.")
    return BigDecimalProgression.fromClosedRange(first, last, if (this.step > java.math.BigDecimal.ZERO) step else -step)
}

/**
 * A progression of values of type `BigDecimal`.
 */
public open class …
Run Code Online (Sandbox Code Playgroud)

bigdecimal kotlin

5
推荐指数
1
解决办法
1398
查看次数

RecyclerView getChildAt(position)返回null

  • 我在我的应用程序中实现Recyclerview,我需要在其项目上单击更新另一个列表视图,这就是为什么我在活动中实现了onClick事件.它工作正常.
  • 但我还需要High Light RecyclerView选择的视图和其他都保持正常.
  • 为此,我使用RecyclerView getChild方法使所有视图正常,然后选择视图突出显示.
  • 我意识到它仅适用于RecyclerView的Visible视图.但是我需要对Recyclerview进行正常的所有视图,如果我使用更大位置的getChildAt,那么总可见计数会返回空指针异常.
    • 记录我得到的

E /项目位置:29

E /项目Rv:15

E/Child适配器:30

MainActivity.java

public class MainActivity extends Activity {
RecyclerView reView;
ArrayList<RvModel> rvModels;
revAdapter adapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    reView = (RecyclerView) findViewById(R.id.reView);
    reView.setLayoutManager(new GridLayoutManager(MainActivity.this, 3));

    rvModels = new ArrayList<>();
    adapter = new revAdapter(MainActivity.this, rvModels);
    reView.setAdapter(adapter);
    prepareData();
    reView.addOnItemTouchListener(new RecyclerItemClickListener(MainActivity.this, reView, new RecyclerItemClickListener.OnItemClickListener() {
        @Override
        public void onItemClick(View view, int position) {
            Log.e("Item Pos", "" + position);
            Log.e("Item Rv", "" + reView.getChildCount());
            Log.e("Child Adapter", "" + …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview

3
推荐指数
1
解决办法
3323
查看次数

顶视图和底视图的相同视图立面看起来不同

最近,我惊讶于一个问题。在我的android手机上,具有相同高度的列表或滚动视图的元素具有与其位置相关的不同阴影。例如,每当屏幕底部的视图具有更暗和更强的阴影时,屏幕顶部的视图将具有较小的光影。这是Google Keep应用程序的屏幕截图:

如果您查看第一个卡片视图和最后一个卡片视图,将会看到不同的阴影

因此,我认为这完全是因为Google Keep应用程序。也许Google的家伙决定为他们的应用程序添加阴影。因此,我创建了一个示例应用程序。

我的布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        style="@style/AppButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:text="Test"/>

    <TextView
        style="@style/AppButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:text="Test"/>

    <TextView
        style="@style/AppButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:text="Test"/>

    <TextView
        style="@style/AppButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:text="Test"/>

    <TextView
        style="@style/AppButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:text="Test"/>

    <TextView
        style="@style/AppButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:text="Test"/>

    <TextView
        style="@style/AppButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:text="Test"/>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我的风格:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item …
Run Code Online (Sandbox Code Playgroud)

android views material-design android-elevation

3
推荐指数
1
解决办法
1236
查看次数

NotificationManager多次通知

目前我通知用户 -

mNotificationManager.notify("My App Name",1212,notification);
Run Code Online (Sandbox Code Playgroud)

这很好用.但它在状态栏中只显示一个图标,但我在不同时间发送了多个通知.

我想为每个通知显示图标(即3个图标).

我不确定是否可能.任何线索?

android android-notifications android-statusbar

2
推荐指数
1
解决办法
464
查看次数