Android Open Source - template-android Main Activity






From Project

Back to project page template-android.

License

The source code is released under:

MIT License

If you think the Android project template-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.org.application.ui.activity;
/*from  w w w  .j a  va  2  s .  c  om*/
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Button;
import android.widget.Toast;

import com.org.application.App;
import com.org.application.R;
import com.org.application.mock.IFoo;

import javax.inject.Inject;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;


/**
 *
 */
public class MainActivity extends Activity {
    private static final String TAG = MainActivity.class.getSimpleName();


    @Inject IFoo mFoo;

    @InjectView(R.id.sampleButton) Button mSampleButton;

    @OnClick(R.id.sampleButton) void toast(){
        Toast.makeText(this, "ButterKnife! " + mFoo.printFoo(), Toast.LENGTH_SHORT).show();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        App app = App.get(this);
        app.inject(this);

        setContentView(R.layout.activity_main);
        ButterKnife.inject(this);


        mSampleButton.setText("Toast ButterKnife!");
        Log.d(TAG, "I am debugging.");
    }
}




Java Source Code List

com.org.application.App.java
com.org.application.Modules.java
com.org.application.Modules.java
com.org.application.Modules.java
com.org.application.mock.Foo.java
com.org.application.mock.IFoo.java
com.org.application.mock.MockFoo.java
com.org.application.module.MockFooModule.java
com.org.application.module.ReleaseModule.java
com.org.application.ui.activity.MainActivity.java
com.org.application.util.Log.java