小编Emi*_*enT的帖子

如何使用Firebase填充RecyclerView适配器

我做了很多研究,但我找不到任何资源如何使用Recycler View Firebase(反之亦然)

有一个Firebase列表适配器,可以从中扩展BaseAdapter.我在Firebase聊天应用程序中找到了它.这是FirebaseListAdapter类.但是RecyclerView使用的适配器需要扩展RecyclerView.Adapter.

你是怎么克服这个问题的?你有什么建议吗?

java android android-layout android-fragments firebase

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

以编程方式执行adb命令时出错

我试图以编程方式执行adb命令

这是我的代码:

File f = new File(Environment.getExternalStorageDirectory(), "screen" + System.currentTimeMillis() + ".png");

new ExecuteCommand(MainActivity.this).execute("adb shell screencap -p "
        + Environment.getExternalStorageDirectory().getPath() +
        "/" + "screen" + System.currentTimeMillis() + ".png");
Run Code Online (Sandbox Code Playgroud)

ExecuteCommand类:

public class ExecuteCommand extends AsyncTask<String, String, String> {

    Context mContext=null;
    public ExecuteCommand(Context _ctx)
    {
        mContext =_ctx;
    }

    ProgressDialog progressdailog;
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        progressdailog = ProgressDialog.show(mContext,
                "Executing", "Please Wait");
    }
    @Override
    protected String doInBackground(String... params) {
        Process p;
        StringBuffer output = new StringBuffer();
        try {
            p = Runtime.getRuntime().exec(params[0]);
            BufferedReader …
Run Code Online (Sandbox Code Playgroud)

shell android screenshot adb

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

将弹出菜单设置为全屏

注意:这是弹出菜单而不是弹出窗口.所以我要求大家仔细阅读.

我已经实现了弹出菜单.它显示在屏幕的一半.我想把它传播到整个设备的宽度.我试图通过设置来改变其风格layout_widthmatch_parent,但没有成功.

以下是我到目前为止所尝试的内容:

样式

 <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->

        <item name="popupMenuStyle">@style/PopupMenu</item>
    </style>

  <!-- Change Overflow Menu Background -->
    <style name="PopupMenu" parent="android:Widget.Holo.Light.ListPopupWindow">
        <item name="android:popupBackground">#888888</item>
        <item name="android:layout_width">match_parent</item>
    </style>
Run Code Online (Sandbox Code Playgroud)

下面是我的java代码:

  PopupMenu menu = new PopupMenu(getActivity(), tvnext);


    for (int i = 0; i < array.size(); i++) {

        menu.getMenu().add(1, i, 1, array.get(i).getAccountName());

    }


    menu.show();

    menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            setUpNextFunctionality(item.getItemId());


            return false;
        }
    });
Run Code Online (Sandbox Code Playgroud)

PS:请不要建议我使用弹出窗口.如果没有任何效果,这是我的最后选择.

android popupmenu

11
推荐指数
2
解决办法
3392
查看次数

配置仍然不正确.你想再次编辑吗?在Android工作室运行应用程序时

在运行我的Android应用程序时,它显示上述错误.我试图更改AVD管理器"使用主机GPU",但无法找到.Android模拟器打开但仍然显示黑屏,甚至没有显示Android的话.我正在使用Mac OS.

android android-studio

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

使用app时更改选项菜单的文字颜色:showAsAction ="always"

我正在使用工具栏和使用选项进行相应的操作.我的问题是我想在白色工具栏上显示"SAVE"文本,我应用了很多样式,但它总是显示为黑色.但是当选项显示为弹出窗口时,文本颜色始终为白色.我谷歌这很多,但没有解决方案.

这是我的代码:

工具栏

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:app="http://schemas.android.com/tools"
    android:id="@+id/my_awesome_toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    app:theme="@android:style/ThemeOverlay.Material.Light"
    app:popupTheme="@style/Theme.AppCompat.NoActionBar"
    android:background="@drawable/tb_header"
    android:minHeight="?attr/actionBarSize"/>
Run Code Online (Sandbox Code Playgroud)

款式

 <style name="MStyle" parent="Theme.AppCompat.Light.NoActionBar">

 <item name="android:windowBackground">@android:color/white</item>
        <item name="android:colorBackground">@android:color/black</item>
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="android:textAllCaps">false</item>
        <item name="android:popupMenuStyle">@style/MyPopupMenu</item>
        <item name="android:panelBackground">@android:color/holo_green_light</item>
        <item name="android:actionBarWidgetTheme">@style/AppTheme</item>

    </style>

<style name ="MyPopupMenu" parent="android:Theme.Holo.Light">
        <item name="android:popupBackground">@android:color/holo_green_light</item>
    </style>


****Option menu**** 

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="com.doubtfire.userprofiles.ParentProfileActivity">
    <item
        android:id="@+id/action_skip"
        android:title="@string/menu_str_skip"

        android:orderInCategory="100"
        app:showAsAction="always" />
</menu>


****I even apply code at onPrepareOptionMenu**** 



   @Override
        public boolean onPrepareOptionsMenu(Menu menu) {
            for (int i=0; i<menu.size(); i++) {
                MenuItem mi = menu.getItem(i);
                String …
Run Code Online (Sandbox Code Playgroud)

android optionmenu material-design android-toolbar

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

进度对话有Lollipop设备的白色背景,

我正在Android 5.0上迁移我的应用程序,即Lollipop设备,我有关于进度对话的问题,它在棒棒糖设备上完美运行,但在棒棒糖上它有白色背景,如图所示 在此输入图像描述

但在棒棒糖前设备中它具有透明背景 在此输入图像描述

以下是我的代码:

布局中的progress.xml

<?xml version="1.0" encoding="utf-8"?>
   <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_gravity="center"
   android:background="@android:color/transparent" >


<ProgressBar
        android:id="@+id/progressBar3"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
       android:background="@android:color/transparent"
        android:layout_centerHorizontal="true"

        android:indeterminate="true"
        android:indeterminateDrawable="@drawable/myprogress"
        android:minHeight="48dp" />
   </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

drawable中的myprogress.xml

<shape
    android:shape="oval"
    android:useLevel="false" >
    <size
        android:height="48dip"
        android:width="48dip" />

    <gradient
        android:centerColor="#ff001100"
        android:centerY="0.50"
        android:endColor="#ffffffff"
        android:startColor="#ff000000"
        android:type="sweep"
        android:useLevel="false" />
</shape>
Run Code Online (Sandbox Code Playgroud)

在Java中我正在使用这样的

public ProgressDialog mProgressDialog;

  if (mProgressDialog != null && mProgressDialog.isShowing()) {
            mProgressDialog.cancel();
        }

        mProgressDialog = new ProgressDialog(context);
        mProgressDialog.setCancelable(false);

        mProgressDialog.show();
        mProgressDialog.setContentView(R.layout.progress);
Run Code Online (Sandbox Code Playgroud)

xml android progressdialog android-layout progress-bar

7
推荐指数
2
解决办法
2999
查看次数

从URL下载图像到SD卡

我正在尝试创建一个非常简单的图像下载应用程序.我想从这个网址下载所有图像到SD卡:https://www.dropbox.com/sh/5be3kgehyg8uzh2/AAA-jYcy_21nLBwnZQ3TBFAea

此代码适用于在imageview中加载图像:

package com.example.imagedownloadsample;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.widget.ImageView;

import com.squareup.picasso.Picasso;

public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.image_download);

        final ImageView img = (ImageView) (findViewById(R.id.imageView1));

        // File file = new File(Environment.getExternalStorageDirectory(),
        // "Android/data/com.usd.pop");

        Picasso.with(getApplicationContext())
                .load("http://8020.photos.jpgmag.com/3456318_294166_528c960558_m.jpg")
                .into(img);

    }

}
Run Code Online (Sandbox Code Playgroud)

但当我尝试这样下载图像到SD卡我最终与不幸的应用程序停止错误:

package com.example.imagedownloadsample;

import java.io.File;

import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.ActionBarActivity;

import com.squareup.picasso.Picasso;
import com.squareup.picasso.Target;

public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.image_download);

        //final ImageView img = (ImageView) …
Run Code Online (Sandbox Code Playgroud)

android http download android-internet

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

我们可以在棒棒糖设备中显示旧式时间选择器(Pre Lollipop Time Picker)

我想在棒棒糖设备中显示较旧的时间选择器(如前棒棒糖设备时间选择器).这可能吗?

android android-timepicker android-5.1.1-lollipop

4
推荐指数
1
解决办法
4463
查看次数

适用于Android的内置单输入文本字段对话框

Android是否附带一个对话框,我可以弹出一个显示单个输入文本字段的"确定"和"取消"按钮,还是我必须自己创建?

android android-dialog

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