forked from roboguice/roboguice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated a few version numbers. Added automatic injection in custom views
Conflicts: .gitignore astroboy/pom.xml roboguice/pom.xml roboguice/src/main/java/roboguice/activity/RoboActivity.java roboguice/src/test/java/roboguice/view/ViewInjectionTest.java
- Loading branch information
1 parent
5e6ce9a
commit f335f01
Showing
4 changed files
with
130 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
android:orientation="horizontal" > | ||
|
||
<TextView | ||
android:id="@+id/tv_status" | ||
android:layout_width="0dp" | ||
android:layout_weight="1" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="20dp" | ||
android:text="TV is open" /> | ||
|
||
<Button | ||
android:id="@+id/close_tv" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="Close TV" /> | ||
|
||
</LinearLayout> |
59 changes: 59 additions & 0 deletions
59
astroboy/src/main/java/org/roboguice/astroboy/view/CustomView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.roboguice.astroboy.view; | ||
|
||
import org.roboguice.astroboy.R; | ||
|
||
import roboguice.inject.InjectView; | ||
import android.annotation.TargetApi; | ||
import android.content.Context; | ||
import android.os.Build; | ||
import android.util.AttributeSet; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.LinearLayout; | ||
import android.widget.TextView; | ||
|
||
public class CustomView extends LinearLayout { | ||
|
||
@InjectView(R.id.close_tv) | ||
private Button buttonCloseTv; | ||
@InjectView(R.id.tv_status) | ||
private TextView textviewStatus; | ||
|
||
@TargetApi(Build.VERSION_CODES.HONEYCOMB) | ||
private CustomView(Context context, AttributeSet attrs, int defStyle) { | ||
super(context, attrs, defStyle); | ||
initializeView(context); | ||
} | ||
|
||
public CustomView(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
initializeView(context); | ||
} | ||
|
||
public CustomView(Context context) { | ||
super(context); | ||
initializeView(context); | ||
} | ||
|
||
public void initializeView(Context context) { | ||
LayoutInflater.from(context).inflate(R.layout.view_custom, this, true); | ||
} | ||
|
||
@Override | ||
protected void onAttachedToWindow() { | ||
super.onAttachedToWindow(); | ||
buttonCloseTv.setOnClickListener(new OnClickListener() { | ||
|
||
public void onClick(View v) { | ||
textviewStatus.setText("Closed"); | ||
} | ||
}); | ||
textviewStatus.setOnClickListener(new OnClickListener() { | ||
|
||
public void onClick(View v) { | ||
textviewStatus.setText("Open"); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters