小编Bin*_*abu的帖子

如何为RecyclerView创建上下文菜单

如何实现上下文菜单RecyclerView?显然调用registerForContextMenu(recyclerView)不起作用.我是从片段中调用它的.有没有人有成功实现这个?

android contextmenu android-recyclerview

89
推荐指数
8
解决办法
7万
查看次数

如何重置Android Studio

我想重置Android Studio 0.2.13为默认状态.这意味着重置所有设置,删除所有项目,所有gradle文件,以便它像新安装一样.为实现这一目标,我必须遵循哪些步骤?

android android-studio

87
推荐指数
10
解决办法
13万
查看次数

无法将Eclipse项目导入Android Studio

每当我尝试将Eclipse项目导入Android Studio时,都会出现以下错误:

您正在使用旧的,不受支持的Gradle版本.请使用1.8或更高版本.请在项目的Gradle设置或项目的Gradle包装器中指向支持的Gradle版本(如果适用).

有关更多详细信息,请参阅IDE日志(帮助|显示日志)

我使用的是Android Studio 0.3和Ubuntu,我也尝试在全新安装的Windows 8机箱上运行但得到同样的错误.我正在使用default gradle wrapper,我尝试检查和取消选中auto import option.这是一个错误吗?我怎么能绕过它呢.如何将gradle更新为1.8或检查当前的gradle版本?

android gradle android-studio

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

对包含ImageView的RecyclerView项目产生连锁反应

我有一个RecyclerView扩展以下网格项:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="@dimen/children_tile_border"
    android:layout_marginTop="@dimen/children_tile_border"
    android:clickable="true"
    android:focusable="true"
    android:background="?selectableItemBackground"
    tools:ignore="RtlHardcoded">

        <com.example.app.ui.widget.SquareImageView
            android:id="@+id/child_picture"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:visibility="visible"
            android:layout_alignParentBottom="true"/>

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="68dp"
            android:background="@color/tile_text_background"
            android:gravity="center_vertical"
            android:layout_alignParentBottom="true">

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

但除非我将SquareImageView's可见性设置为不可见,否则不会出现涟漪效应.似乎涟漪效应低于SquareImageView.我怎么能把它画成SquareImageView

android ripple android-recyclerview

42
推荐指数
3
解决办法
3万
查看次数

DialogFragment:将AlertDialog与自定义布局一起使用

我正在用Fragments API支持重写我的应用程序.在原始应用程序中,我有一个AlertDialog这样的:

    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.button_dialog, null);
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setView(view);
    ListView mListView = (ListView) view.findViewById(R.id.mblist);
    builder.setTitle(getString(R.string.sysinfo)).setNeutralButton(
            getString(R.string.okay), null);
    Cursor dcursor = propManager.propCursor();
    if (dcursor.moveToFirst()) {
        startManagingCursor(dcursor);
        String[] from = { Constants.NAME_DET,
                Constants.VALUE_DET };
        int[] to = { R.id.mbname, R.id.mbvalue };
        SimpleCursorAdapter dadapter = new SimpleCursorAdapter(this,
                R.layout.info_list_row, dcursor, from, to);
        mListView.setAdapter(dadapter);
    }
    final Dialog dialog = builder.create();
    dialog.show();
Run Code Online (Sandbox Code Playgroud)

如何通过DialogFragment显示相同的对话框?我已阅读文档,但无法弄清楚如何继续这样做.

android android-fragments android-alertdialog

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

Android中的HttpUrlConnection设置范围将被忽略

我正在尝试使用Android从我的服务器获得206响应.

这是代码.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            try {
                URL url = new URL("http://aviddapp.com/10mb.file");
                HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
                urlConnection.setRequestProperty("Range", "bytes=1-2");
                urlConnection.connect();

                System.out.println("Response Code: " + urlConnection.getResponseCode());
                System.out.println("Content-Length: " + urlConnection.getContentLength());
                Map<String, List<String>> map = urlConnection.getHeaderFields();
                for (Map.Entry<String, List<String>> entry : map.entrySet()) {
                    System.out.println("Key : " + entry.getKey() +
                            " ,Value : " + entry.getValue());
                }
                InputStream inputStream = urlConnection.getInputStream();
                long size = 0;

                while(inputStream.read() != …
Run Code Online (Sandbox Code Playgroud)

java android httpurlconnection

19
推荐指数
2
解决办法
1742
查看次数

onSingleTapConfirmed和onSingleTapUp之间的区别

之间有什么区别onSingleTapConfirmedonSingleTapUpGestureDetector.SimpleOnGestureListener?其中哪一个类似于onClick方法?

android onclick touch gesture

17
推荐指数
1
解决办法
5366
查看次数

第二次调用时,DatePicker的setMinDate(...)不起作用

我处于一种特殊的情况,我必须DatePicker根据a的所选元素改变最小和最大日期Spinner.这是我用来切换最小和最大日期的代码块.

private void switchCalculationMethod(int method) {
    calculationMethod = method;
    switch (method) {
        case METHOD_1:
            datePicker.setMinDate(new LocalDate().minusWeeks(42).getMillis());
            datePicker.setMaxDate(new LocalDate().plusDays(1).getMillis() - 1);
            break;
        case METHOD_2:
            datePicker.setMinDate(new LocalDate().minusWeeks(2).getMillis()); // This don't work!!
            datePicker.setMaxDate(new LocalDate().plusWeeks(40).getMillis()); // This works!!!
            break;
    }
    datePicker.init(today.getYear(), today.getMonthOfYear() - 1,
            today.getDayOfMonth(), this);
}
Run Code Online (Sandbox Code Playgroud)

因此,DatePicker第一次正确设置,当我尝试再次更改最小日期(更改最大日期工作)时出现问题.它将保持我先设定的值.我在想这是一个错误.我在这里做错了吗?这有解决方法吗?

PS:我正在使用Joda时间api.

time android date android-ui

16
推荐指数
1
解决办法
3381
查看次数

无法在null对象上调用void android.view.View.setTranslationZ(float)

我在我的项目中使用库recyclerview-multiselect在recyclerview上选择多个项目在三星设备上:当我长按并选择一个项目时,多重选择器启动但是一旦我取消选择最后一个选择的项目我就会得到以下异常这只发生在三星设备

JNI DETECTED ERROR IN APPLICATION: can't call void android.view.View.setTranslationZ(float) on null object
in call to CallVoidMethodV
from void android.animation.PropertyValuesHolder.nCallFloatMethod(java.lang.Object, long, float)
"main" prio=5 tid=1 Runnable
| group="main" sCount=0 dsCount=0 obj=0x86d99ef0 self=0xb4d07800
| sysTid=28321 nice=0 cgrp=apps sched=0/0 handle=0xb6f9dec8
| state=R schedstat=( 1263638622 186444747 1521 ) utm=90 stm=36 core=1 HZ=100
| stack=0xbe20a000-0xbe20c000 stackSize=8MB
| held mutexes= "mutator lock"(shared held)
native: #00 pc 00004c58  /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+23)
native: #01 pc 000034c1  /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+8)
native: #02 pc 002590fd  /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, …
Run Code Online (Sandbox Code Playgroud)

android samsung-mobile android-recyclerview

16
推荐指数
1
解决办法
2444
查看次数

无限期地将Runnable从java转换为kotlin

我在监视某个文件的java中有这样的代码:

private Handler mHandler = new Handler();
private final Runnable monitor = new Runnable() {

    public void run() {
        // Do my stuff
        mHandler.postDelayed(monitor, 1000); // 1 second
    }
};
Run Code Online (Sandbox Code Playgroud)

这是我的kotlin代码:

private val mHandler = Handler()
val monitor: Runnable = Runnable {
    // do my stuff
    mHandler.postDelayed(whatToDoHere, 1000) // 1 second
}
Run Code Online (Sandbox Code Playgroud)

我不明白Runnable我应该传递什么mHandler.postDelayed.什么是正确的解决方案?另一件有趣的事情是,当我提供这段代码时,kotlin到java转换器会冻结.

java android kotlin

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