码迷,mamicode.com
首页 > 其他好文 > 详细

Dhroid框架配置

时间:2015-08-31 13:15:08      阅读:271      评论:0      收藏:0      [点我收藏+]

标签:

1.将dhroid文件夹作为一个Module导入,dhroid下载地址

技术分享

2.在build.gradle中的dependencies节点中添加compile project(‘:dhroid‘)

dependencies {
    compile fileTree(dir: libs, include: [*.jar])
    compile project(:dhroid)
}

3.配置AndroidManifest文件中application节点添加MyApplication(继承Application,在onCreate()方法中实现dhroid初始化)

Manifest文件配置(app目录下面)

<?xml version="1.0" encoding="utf-8"?>
<manifest
    package="com.example.administrator.myapplication"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:versionCode="100"
    android:versionName="1.0.1">
    <application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:hardwareAccelerated="false"
        android:icon="@mipmap/ic_launcher"
        android:theme="@style/AppTheme"
        tools:replace="android:icon, android:theme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>
    <!-- 权限配置,这里省略了-->

</manifest>

MyApplication.java文件配置

import android.app.Application;
import net.duohuo.dhroid.Const;
import net.duohuo.dhroid.Dhroid;

/**
 * Author:JsonLu
 * DateTime:2015/8/31 09:13
 * Email:luxd@i_link.cc
 */
public class MyApplication extends Application{
    @Override
    public void onCreate() {
        super.onCreate();
        dhroidint();// 初始化dhroid参数
    }
    // dhroidint开发框方法初始化
    private void dhroidint() {
        Const.netadapter_page_no = "request.pageNum";
        Const.netadapter_step = "request.pageSize";
        Const.response_data = "page1";
        Const.netadapter_step_default = 10;
        Const.netadapter_json_timeline = "pubdate";
        Const.DATABASE_VERSION = 20;
        Const.net_pool_size = 30;
        Const.net_error_try = true;
        Dhroid.init(this);
    }
}

4.在MainActivity中继承BaseActivity(一定)

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import net.duohuo.dhroid.activity.BaseActivity;
import net.duohuo.dhroid.ioc.annotation.InjectView;
/**
 * Author:JsonLu
 * DateTime:2015/8/31 09:13
 * Email:luxd@i_link.cc
 */
public class MainActivity extends BaseActivity {

    @InjectView(id = R.id.name,click = "changeValue") TextView Name;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Name.setText("点我");
    }

    public void changeValue(View v){
        Name.setText(String.valueOf(System.currentTimeMillis()));
    }


}

测试项目下载

 

Dhroid框架配置

标签:

原文地址:http://www.cnblogs.com/Jsonlu/p/4772736.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!