12-5

1  Android stdio导入项目一直卡在build gradle project info。

AndroidStudio导入项目一直卡在Building gradle project info,实际上是因为你导入的这个项目使用的gradle与你已经拥有的gradle版本不一致,导致需要下载该项目需要的gradle版本,不知是被墙了还是什么原因,反正就是会一直卡住,直至下载完成(如果能下载完成的话,233)

网上也提供了方法,就是去官网下载gradle的版本,然后放到本地,我就不在这里介绍了,我的解决方法更简单一些,就是直接修改gradle-wrapper.properties文件,无需去下载gradle

 

解决方案

1.随便找一个你能运行的as项目

2.打开gradle-wrapper.properties,文件目录:项目/gradle/wrapper/gradle-wrapper.properties

3.复制distributionUrl这一整行的内容,eg: distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip

4.打开你要导入的项目的gradle-wrapper.properties,具体步骤与步骤2相同

5.把步骤3复制的内容,替换你要导入的项目的gradle-wrapper.properties文件的distributionUrl这一行

6.再重启as,导入项目就可以了


2  failed to find Build Tools revision 23.0.1

直接去sdk manager那里下载Build Tools 对应的版本。。

使用android-support-design实现MD风格对话框

说明: 
1.在新版的android.support.v7包中,Google提供了一个新的AlertDialog类,即android.support.v7.app.AlertDialog。使用该类中的Builder可以直接创建Material Design风格的对话框,而不需要再借助于第三方库。(即第一张图的效果)

2.遗憾的是,上述第二张图中转圈样式的ProgressBar暂无法使用系统组件。本例中使用的第三方库来自:

compile 'com.github.rahatarmanahmed:circularprogressview:2.4.0'
 
 
  • 1
  • 1

3.代码不多,并已简单封装为工具类:

package com.sinatj.demo.utils;

import android.content.Context;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.sinatj.demo.R;

/**
 * UiUtil.
 * Created by admin on 15-12-22.
 */
public class UiUtil {
    private static AlertDialog showDialog(Context context, String title, String message, View contentView,
                                          String positiveBtnText, String negativeBtnText,
                                          DialogInterface.OnClickListener positiveCallback,
                                          DialogInterface.OnClickListener negativeCallback,
                                          boolean cancelable) {

        AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AppCompatAlertDialogStyle);
        builder.setTitle(title == null ? "提示" : title);
        if (message != null) {
            builder.setMessage(message);
        }

        if (contentView != null) {
            builder.setView(contentView);
        }

        if (positiveBtnText != null) {
            builder.setPositiveButton(positiveBtnText, positiveCallback);
        }

        if (negativeBtnText != null) {
            builder.setNegativeButton(negativeBtnText, negativeCallback);
        }

        builder.setCancelable(cancelable);
        return builder.show();
    }

    //普通对话框
    public static AlertDialog showSimpleDialog(Context context, String title, String message,
                                               String positiveBtnText, String negativeBtnText,
                                               DialogInterface.OnClickListener positiveCallback,
                                               DialogInterface.OnClickListener negativeCallback,
                                               boolean cancelable) {

        return showDialog(context, title, message, null, positiveBtnText, negativeBtnText, positiveCallback, negativeCallback, cancelable);
    }

    //带ProgressBar的对话框
    public static AlertDialog showProgressDialog(Context context, String title, String message,
                                                 String positiveBtnText, String negativeBtnText,
                                                 DialogInterface.OnClickListener positiveCallback,
                                                 DialogInterface.OnClickListener negativeCallback,
                                                 boolean cancelable) {

        View view = LayoutInflater.from(context).inflate(R.layout.circular_progressbar, null);
        if (message != null) {
            final TextView messageTv = (TextView) view.findViewById(R.id.progressbar_msg);
            messageTv.setText(message);
        }

        return showDialog(context, title, null, view, positiveBtnText, negativeBtnText, positiveCallback, negativeCallback, cancelable);
    }
}

 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71

4.circular_progressbar布局文件,由一个第三方库提供的ProgressBar和一个TextView组成:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="20dp">

    <com.github.rahatarmanahmed.cpv.CircularProgressView
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:orientation="vertical"
        app:cpv_animAutostart="true"
        app:cpv_indeterminate="true" />

    <TextView
        android:id="@+id/progressbar_msg"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16dp"
        android:layout_gravity="center_vertical"
        android:textSize="16sp"
        android:textColor="#111111"
        android:text="@string/main_waiting"/>
</LinearLayout>
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25

5.AppCompatAlertDialogStyle为对话框的样式,可指定文字颜色、按钮颜色、背景色等。(本例中使用的时默认值)

<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
        <!--对话框按钮文字颜色-->
        <item name="colorAccent">#FFCC00</item>
        <!--对话框内容文字颜色-->
        <item name="android:textColorPrimary">#FFFFFF</item>
        <!--对话框背景色-->
        <item name="android:background">#5fa3d0</item>
    </style>
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

本篇完,欢迎讨论、交流。



package com.small.saasdriver.utils;

import android.content.Context;

import me.itangqi.greendao.DaoMaster;
import me.itangqi.greendao.DaoSession;

/**
 * Created by Administrator on 2016/12/1 0001.
 */
public class DBManager {


    private static DBManager instance;
    private DaoMaster daoMaster;
    private DaoSession daoSession;

    /**
     * [获取DBManager实例,单例模式实现]
     *
     * @param context
     * @return
     */
    public static DBManager getInstance(Context context) {
        if (instance == null) {
            synchronized (DBManager.class) {
                if (instance == null) {
                    instance = new DBManager(context);
                }
            }
        }
        return instance;
    }

    /**
     * 构造方法
     * @param context
     */
    private DBManager(Context context) {
        if(daoSession == null){
            if(daoMaster == null){
                DaoMaster.OpenHelper helper = new DaoMaster.DevOpenHelper(context, context.getPackageName(), null);
                daoMaster = new DaoMaster(helper.getWritableDatabase());
            }
            daoSession = daoMaster.newSession();
        }
    }

    public DaoMaster getDaoMaster() {
        return daoMaster;
    }

    public void setDaoMaster(DaoMaster daoMaster) {
        this.daoMaster = daoMaster;
    }

    public DaoSession getDaoSession() {
        return daoSession;
    }

    public void setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
    }










}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值