小编Dev*_*ath的帖子

如何更改android中自定义警报对话框中的正负按钮的颜色

我在做什么:我正在创建一个自定义警报对话框

我想做什么:以及下面的代码,如何更改对话框中的操作按钮的颜色(正面和负面)

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    // Get the layout inflater
    LayoutInflater inflater = getActivity().getLayoutInflater();

    // Inflate and set the layout for the dialog
    // Pass null as the parent view because its going in the dialog layout
    builder.setView(inflater.inflate(R.layout.dialog_signin, null))
    // Add action buttons
           .setPositiveButton(R.string.signin, new DialogInterface.OnClickListener() {
               @Override
               public void onClick(DialogInterface dialog, int id) {
                   // sign in the user ...
               }
           })
           .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
               public void onClick(DialogInterface …
Run Code Online (Sandbox Code Playgroud)

android android-alertdialog

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

在android中实现Simple SeekBar

Filters.java

public class Filters extends Activity implements OnSeekBarChangeListener{
    private SeekBar PRICEbar,DISTANCEbar, RATINGbar; // declare seekbar object variable
    // declare text label objects
    private TextView PRICEtextProgress,DISTANCEtextProgress, RATINGtextProgress;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        // load the layout
        setContentView(R.layout.filters);     
        PRICEbar = (SeekBar)findViewById(R.id.PRICEseekBarID); // make seekbar object
        PRICEbar.setOnSeekBarChangeListener(this); 
        PRICEbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                // TODO Auto-generated method …
Run Code Online (Sandbox Code Playgroud)

xml android seekbar

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

使用android中的数据绑定检测回收器视图中的onClick

  1. 我正在参考用于数据绑定的vogella-tutorial
  2. 我想做的是:使用dataBinding检测每个Item的回收器视图行中的onClick的最佳方法是什么

activity_second.xml

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">

    <data>
        <variable
            name="temp"
            type="com.vogella.android.databinding.TemperatureData" />
        <variable
            name="presenter"
            type="com.vogella.android.databinding.MainActivityPresenter"/>
    </data>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/my_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="vertical" />
</layout>
Run Code Online (Sandbox Code Playgroud)

rowlayout.xml

<layout xmlns:android="http://schemas.android.com/apk/res/android">

    <data>

        <variable
            name="obj"
            type="com.vogella.android.databinding.TemperatureData"
            />
    </data>

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="?android:attr/listPreferredItemHeight"
        android:padding="6dip"
        >

        <ImageView
            android:id="@+id/icon"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_alignParentBottom="true"
            android:layout_alignParentTop="true"
            android:layout_marginRight="6dip"
            android:contentDescription="TODO"
            android:src="@drawable/ic_listentry"
            />

        <TextView
            android:id="@+id/secondLine"
            android:layout_width="fill_parent"
            android:layout_height="26dip"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:layout_toRightOf="@id/icon"
            android:ellipsize="marquee"
            android:text="@{obj.location}"
            android:textSize="12sp"
            android:maxLines="1"
        />

        <TextView
            android:id="@+id/firstLine"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_above="@id/secondLine"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_alignWithParentIfMissing="true"
            android:layout_toRightOf="@id/icon"
            android:gravity="center_vertical"
            android:text="@{obj.celsius}"
            android:textSize="16sp"
            />

    </RelativeLayout>

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

MyAdapter.java

public class …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview android-databinding

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

在android项目中使用谷歌地方选择器

我正在尝试学习 谷歌的地方选择器

  1. 我从这里使用了示例项目
  2. 我已经为示例项目链接了playservices库
  3. 解决了所有依赖项

问题:

一些依赖性没有得到解决,

import com.google.android.gms.location.places.Place;
import com.google.android.gms.location.places.ui.PlacePicker;
Run Code Online (Sandbox Code Playgroud)

题:

  1. 怎么解决这个问题
  2. 我是否需要添加任何其他项目引用

android google-play-services

9
推荐指数
1
解决办法
7222
查看次数

尝试在空对象引用上调用虚方法'android.content.res.AssetManager android.content.res.Resources.getAssets()'

怎么了:

  1. 我有一个来自appstore的堆栈跟踪,如下所示,我面临的问题是它不会显示哪个类导致了这个崩溃.
  2. 我可以理解的是,由于我使用过的资产导致了它的原因
  3. 只有在我使用资产的位置才能在应用程序级别设置字体

码:

private void setDefaultFont() {

        try {
            final Typeface bold = Typeface.createFromAsset(getAssets(), "fonts/OpenSans-Bold.ttf");
            final Typeface italic = Typeface.createFromAsset(getAssets(), "fonts/OpenSans-Italic.ttf");
            final Typeface boldItalic = Typeface.createFromAsset(getAssets(), "fonts/OpenSans-BoldItalic.ttf");
            final Typeface regular = Typeface.createFromAsset(getAssets(),"fonts/OpenSans-Regular.ttf");

            Field DEFAULT = Typeface.class.getDeclaredField("DEFAULT");
            DEFAULT.setAccessible(true);
            DEFAULT.set(null, regular);

            Field DEFAULT_BOLD = Typeface.class.getDeclaredField("DEFAULT_BOLD");
            DEFAULT_BOLD.setAccessible(true);
            DEFAULT_BOLD.set(null, bold);

            Field sDefaults = Typeface.class.getDeclaredField("sDefaults");
            sDefaults.setAccessible(true);
            sDefaults.set(null, new Typeface[]{
                    regular, bold, italic, boldItalic
            });

        } catch (NoSuchFieldException e) {
           // logFontError(e);
        } catch (IllegalAccessException e) {
           // logFontError(e);
        } catch (Throwable e) { …
Run Code Online (Sandbox Code Playgroud)

android android-assets

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

Flutter:未实现的丢失静态目标的处理

  1. 我正在运行我的第一个Flutter项目
  2. 我创建了一个示例项目,并能够在模拟器中运行该应用程序

我已经编辑了文件 main.dart

主镖

import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(home: Text('Hello World')));
Run Code Online (Sandbox Code Playgroud)

现在我得到了错误:

在此处输入图片说明

pubspec.yaml

name: flutter_app
description: A new Flutter application.

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In …
Run Code Online (Sandbox Code Playgroud)

flutter

9
推荐指数
9
解决办法
3617
查看次数

什么是Android中的RoboSpice库

我正在尝试了解android中的RoboSpice库


我在这里看到了在线文档


我尝试了什么 ::

  • 我以前研究过使用Spring Library,还有Retrofit,AsyncHttp等
  • 我明白以上所有转换JSON响应POJO

我需要更多信息 ::

  • 当我看到文件上Robospice,它看起来像周围的任何包装SpringRetrofitAsyncHttp
  • 这是真的吗?
  • 因此,通过使用RoboSpice我们可以选择底层是 SpringRetrofitAsyncHttp
  • 因此,如果出现这种情况RoboSpice使SpringRetrofitAsyncHttp等作为样板代码,使开发更容易

如果我不对,请提供明确的信息


我是android的新手,请轻松回答问题

java android robospice

8
推荐指数
1
解决办法
5297
查看次数

Android Studio和Eclipse之间的区别,用于开发和调试

使用android studio而不是eclipse的pro和con是什么?


注意 ::我已经查看了CommonsWare 在这里回答的答案,但在调试工具中并不是很清楚


  1. Android Studio是否提供不在eclipse中的特殊调试功能?

  2. 如果是这样的话是什么?

eclipse android android-studio

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

使用黄油刀库视图注射

我在做什么 ::

  1. 我试图运行黄油刀库对于我的简单项目
  2. 我已经按照文档中的所有步骤进行操作,但仍然遇到日志错误
  3. 我怎么能解决这个问题,我错过了任何一步
  4. 我还在libs文件夹中添加了jar

MainActivity.java

package com.example.butterknife;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import butterknife.ButterKnife;
import butterknife.InjectView;

public class MainActivity extends Activity {

    @InjectView(R.id.txtID) TextView title;

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

        ButterKnife.inject(this);
        title.setText("Hello Everyone !!");

    }
}
Run Code Online (Sandbox Code Playgroud)

记录 ::

04-15 11:50:57.845: E/AndroidRuntime(913): FATAL EXCEPTION: main
04-15 11:50:57.845: E/AndroidRuntime(913): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.butterknife/com.example.butterknife.MainActivity}: java.lang.NullPointerException
04-15 11:50:57.845: E/AndroidRuntime(913):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
04-15 11:50:57.845: E/AndroidRuntime(913):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
04-15 11:50:57.845: E/AndroidRuntime(913):  at android.app.ActivityThread.access$600(ActivityThread.java:122)
04-15 11:50:57.845: E/AndroidRuntime(913): …
Run Code Online (Sandbox Code Playgroud)

android butterknife

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

Android Exoplayer中PlayerView和StyledPlayerView有什么区别

玩家视图

<com.google.android.exoplayer2.ui.PlayerView
    android:id="@+id/exoplayerView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:controller_layout_id="@layout/layout_exoplayer_control_views"
    app:use_controller="true">
Run Code Online (Sandbox Code Playgroud)

样式化的播放器视图

<com.google.android.exoplayer2.ui.StyledPlayerView
    android:id="@+id/exoplayerView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:controller_layout_id="@layout/layout_exoplayer_control_views"
    app:use_controller="true">
Run Code Online (Sandbox Code Playgroud)
  • 它们之间的主要区别是什么。
  • 何时使用哪一种以及在什么场景下使用。
  • 两者都可以定制app:controller_layout_id,为什么会有两种不同类型的播放器

android kotlin exoplayer

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