小编Mar*_*cus的帖子

RecyclerView:如何创建插入动画效果?

ReyclerView和a LinearLayoutManager和a 一起工作Adapter<ViewHolder>.我有一个项目列表,我想在recyclelerview中显示插入(幻灯片放入)动画.我该怎么做?

我想根据项目的索引显示具有线性增加延迟的动画.

目前,如果我使用2个按钮,'添加'和'删除',然后在recyclerview上执行相应的操作(notifyItemInserted()并且notifyItemRemoved(),动画很好地进行.

如果我以编程方式循环数据集并添加项目,再次使用notifyItemInserted(),我没有看到任何动画.我只看到所有项目几乎同时出现.

如果我使用具有线性延迟的Asynctasks,然后添加/删除项目OnPostExecute(),我仍然看不到任何动画.此外,如果多个插入线程正在等待所有删除线程完成(没有删除线程运行的位置),我看到可能会遇到死锁.

我究竟做错了什么 ?

我已经在SO上经历了与此相关的大部分问题,并且花了几天时间围绕着Recyclerview的动画部分,仍然没有运气.

animation android delay android-recyclerview

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

从URL下载图像并将其保存到内部存储内存的最佳方式

我正在开发一个应用程序,我想从URL下载图像.我需要立即下载这些图像并将其存储到内部存储中.有200多张图片供下载.请告诉我在最短的时间内下载这些图像的最佳方法.如果有任何第三方库,请告诉我们.

android

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

Android Espresso ListView点击项目

我有ListView图片和文字.当我尝试点击项目时,我收到错误

android.support.test.espresso.AmbiguousViewMatcherException: 'with id: com.cifrasoft.telefm:id/cardsGridView' matches multiple views in the hierarchy.
Problem views are marked with '****MATCHES****' below.
Run Code Online (Sandbox Code Playgroud)

我使用以下代码:

onData(hasToString(startsWith("Item Text")))
            .inAdapterView(withId(R.id.cardsGridView))
            .perform(click());
Run Code Online (Sandbox Code Playgroud)

我可以点击ListView使用位置Adapter,没有匹配或startWith

android ui-testing android-listview android-espresso

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

如何通过焦点在屏幕上调整两个片段的大小?

我有三个片段,前两个填充80%的屏幕,最后一个填充其余的片段(这个片段永远不会改变大小).我希望,在用户(焦点)输入片段后,调整片段的大小,使其填满屏幕的70%(将10%留给另一个).像这样:

在此输入图像描述

可以通过动态改变碎片的重量吗?或者有更好的方法来实现这一目标?

这是我现在在XML中的代码:

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <FrameLayout android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:weightSum="1.0">

            <FrameLayout android:id="@+id/containerParent"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight=".8">

                <LinearLayout
                    android:id="@+id/MainLinear"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:orientation="vertical"
                    android:weightSum="1.0">

                    <FrameLayout android:id="@+id/fragment1"
                        android:layout_width="fill_parent"
                        android:layout_height="0dp"
                        android:layout_weight=".5"/>

                    <FrameLayout android:id="@+id/fragment2"
                        android:layout_width="fill_parent"
                        android:layout_height="0dp"
                        android:layout_weight=".5"/>

                </LinearLayout>

            </FrameLayout>


            <FrameLayout android:id="@+id/fragment3"
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_weight=".2"/>


        </LinearLayout>

    </FrameLayout>


</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

android android-fragments android-layout-weight

7
推荐指数
1
解决办法
1371
查看次数

没有RECORD_AUDIO的Android Visualizer使用权限

我正在使用一个简单的Visualizer类(请参见下文)以可视化该类的音频输出MediaPlayer。但是,这要求android.permission.RECORD_AUDIO似乎吓退了用户。有什么方法可以达到相同的结果,但不是android.permission.RECORD_AUDIO吗?

可视化工具代码:

private void setupVisualizerFx() {
    int audioSessionId = service.getAudioSessionId();
    if (mVisualizer != null) {
        mVisualizer.setEnabled(false);
    }
    mVisualizer = new Visualizer(audioSessionId);
    mVisualizer.setEnabled(false);
    try {
        mVisualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1]);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    mVisualizer.setDataCaptureListener(
            new Visualizer.OnDataCaptureListener() {
                public void onWaveFormDataCapture(Visualizer visualizer,
                        byte[] bytes, int samplingRate) {
                    mVisualizerView.updateVisualizer(bytes);
                }

                public void onFftDataCapture(Visualizer visualizer,
                        byte[] bytes, int samplingRate) {
                }
            }, Visualizer.getMaxCaptureRate() / 2, true, false);
}

/**
 * A simple class that draws waveform data received …
Run Code Online (Sandbox Code Playgroud)

android

6
推荐指数
0
解决办法
337
查看次数

Visual Studio 2013:"未选择任何框架版本,您必须在创建项目之前选择一个."

我最近在笔记本电脑上安装了Visual Studio 2013(Windows 8.1),在尝试创建项目时遇到了麻烦.

我被提示选择框架版本,但框架列表为空.见下图.

空

正如我在msdn上看到的那样,.NET框架版本4.5应该包含在Visual Studio 2013中,但正如您所看到的,它不在我的框架列表中.

我试图手动安装4.5.3版但问题仍然存在.

我该如何解决这个问题?

.net .net-framework-version visual-studio-2013

6
推荐指数
1
解决办法
6637
查看次数

如何在Android中每20秒调用一次方法

我想编写一个Android应用程序,打开后20秒后调用一个方法,然后每隔10秒调用一次方法.

有关如何进行的任何想法?

android thread-safety

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

Android 显示通知不起作用

目前我有一个播放音乐的服务。我想在服务开始播放音乐时显示通知。这就是我所做的:

public void setUpNotification() {
    /*
     * Set up the notification for the started service
     */

    Notification.Builder notifyBuilder = new Notification.Builder(this);
    notifyBuilder.setTicker("ticker");
    notifyBuilder.setOngoing(true);
    notifyBuilder.setContentTitle("title");
    notifyBuilder.setContentInfo("content info");

    // set up an Intent if the user clicks the notification
    int NOTIFICATION_ID = 1;
    Intent notifyIntent = new Intent(this, MainActivity.class);

    notifyIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
            | Intent.FLAG_ACTIVITY_SINGLE_TOP);

    PendingIntent pi = PendingIntent.getActivity(this, 0, notifyIntent,
            NOTIFICATION_ID);

    notifyBuilder.setContentIntent(pi);
    Notification notification = notifyBuilder.build();
    // start ongoing
    startForeground(NOTIFICATION_ID, notification);
}
Run Code Online (Sandbox Code Playgroud)

该方法在服务 playMusic() 中被调用,如下所示:

public void playMusic(String songPath) {
    if(mPlayer == null || …
Run Code Online (Sandbox Code Playgroud)

android android-intent android-notifications

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

更改整个 html 文档的 FontSize 的简单方法

是否有任何标准方法可以更改整个 HTML 文档的字体大小?

我正在考虑两个按钮,一个增加字体大小,另一个减少字体大小。这两个按钮都调用一个 JavaScript 函数;

function increaseFontSize(){
//Increase the font size for the whole document
}

function decreaseFontSize(){
//Decrease the font size for the whole document
}
Run Code Online (Sandbox Code Playgroud)

我该怎么做呢?有没有比我上面说的更简单的方法?

编辑

我正在使用Bootstrap,它为每个 HTML 元素提供了自己的 CSS。Bootstrap 将默认(正文)字体大小定义为14px

html javascript css jquery

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

在 Android 中通过 OTG 电缆使用连接的 USB 播放视频?

我想问一下,有可用的应用程序,用户可以通过 OTG 电缆设备将 USB 连接到 Android 并播放其中包含的媒体(特别是视频)。

我制作了一个广播接收器来检测连接的 USB,我也想阅读内容。我正在使用此代码片段。

                    private final BroadcastReceiver mUsbReceiver = new BroadcastReceiver() {

                            public void onReceive(Context context, Intent intent) {
                                String action = intent.getAction();
                                if (UsbManager.ACTION_USB_DEVICE_DETACHED.equals(action)) {
                                    synchronized (this) {
                                        UsbDevice device = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);

                                        if(device != null){
                                              //                        
                                            Log.d("1","DEATTCHED-" + device);
                                          }
                                    }
                                }
                    //
                                if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(action)) {
                                    synchronized (this) {
                                        UsbDevice device = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
                                        if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {

                                            if(device != null){
                                              //

                                                Log.d("1","ATTACHED-" + device);
                                           }
                                        } 
                                        else {
                                            PendingIntent mPermissionIntent;
                                            mPermissionIntent = PendingIntent.getBroadcast(MainActivity.this, 0, …
Run Code Online (Sandbox Code Playgroud)

usb video android usb-otg

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