編輯:關於android開發

Module -> Component -> Application
首先模塊(Module)創建需要提供的類實例, 其次把模塊添加到組件(Component)中並提供需要注入的類, 最後把組件添加到應用(Application)中並提供接口.
// 模塊
@Module
public class TestAppModule {
private final Context mContext;
public TestAppModule(Context context) {
mContext = context.getApplicationContext();
}
// 提供類實例
@AppScope
@Provides
public Context provideAppContext() {
return mContext;
}
@Provides
public WeatherApiClient provideWeatherApiClient() {
return new MockWeatherApiClient();
}
}
// 組件
@AppScope
@Component(modules = TestAppModule.class) // 注冊模塊
public interface TestAppComponent extends AppComponent {
void inject(MainActivityTest test);
}
// 應用
public class TestWeatherApplication extends WeatherApplication {
private TestAppComponent mTestAppComponent;
@Override public void onCreate() {
super.onCreate();
mTestAppComponent = DaggerTestAppComponent.builder()
.testAppModule(new TestAppModule(this))
.build();
}
// 提供組件
@Override
public TestAppComponent getAppComponent() {
return mTestAppComponent;
}
}
Android調試工具, 不用編譯, 就可以刷新一些項目修改. 不過功能已經被Android Studio 2.0 代替, 等待2.0正式發版.
DataBinding實現數據與頁面的分離, 更符合面向對象的編程模式.
布局設置
<code class="hljs haskell"> <data>
<variable name="weatherData" type="clwang.chunyu.me.wcl_espresso_dagger_demo.data.WeatherData">
</variable></data>
<textview android:id="@+id/temperature" android:layout_centerinparent="true" android:layout_height="wrap_content" android:layout_marginbottom="@dimen/margin_large" android:layout_margintop="@dimen/margin_xlarge" android:layout_width="wrap_content" android:text="@{weatherData.temperatureCelsius}" android:textappearance="@style/TextAppearance.AppCompat.Display3" tools:text="10°"></textview></code>
邏輯設置
private ActivityMainBinding mBinding; // 頁面綁定類
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_main); // 綁定頁面
mBinding.weatherLayout.setVisibility(View.VISIBLE); // 使用Id
mBinding.setWeatherData(weatherData); // 綁定數據
查看Apk信息的軟件, 功能非常強大, 省去反編譯的步驟, 主要功能:
(1) 在MultiDex中dex的詳細信息.
(2) 使用NativeLibrary的詳細信息.
(3) 類的詳細信息.
(4) 數量統計.
升級Mac系統, 可能會導致Pod命令消失, 需要重新安裝Pod.
sudo gem install -n /usr/local/bin cocoapods
LaunchMode包含四種模式,
(1) standard, 標准模式, 啟動重新創建示例, 默認.
(2) singleTop, 棧頂復用模式, 位於棧頂, 啟動不會被創建, 調用onNewIntent.
(3) singleTask, 棧內復用模式, 存在不會被創建, 調用onNewIntent.
(4) singleInstance, 單實例模式, 單獨位於一個任務棧內, 復用.
OK, That’s all! Enjoy It
【Android】不彈root請求框檢測手機是否root,androidroot
【Android】不彈root請求框檢測手機是否root,androidroot由於項目需要root安裝軟件,並且希望在合適的時候引導用戶去開啟root安裝,故需要檢測手
android 和Ubuntu 同步使用Xmind
android 和Ubuntu 同步使用Xmind故事起源於我一直習慣於使用腦圖來整理思路,平時使用Xmind利用金山的快盤在辦公室和家裡的機器之間自動同步,很方便。最近
Android專用Log開源項目——KLog
Android專用Log開源項目——KLog 在Android開發和調試的過程中,Log的使用是非常頻繁的,一個好的Log工具可以幫你節省很多時間,所以凱子哥抽空寫了個
Android之QQ新用戶注冊界面1,android新用戶注冊
Android之QQ新用戶注冊界面1,android新用戶注冊還沒到睡覺時間所以再加了一個界面... 問題: 1、下拉列表(因為還沒看到這裡...) 2、標題欄顯示問題