add initial state attribute to FoldableLinearLayout
This commit is contained in:
@@ -56,6 +56,7 @@ public class FoldableLinearLayout extends LinearLayout {
|
|||||||
|
|
||||||
private String mFoldedLabel;
|
private String mFoldedLabel;
|
||||||
private String mUnFoldedLabel;
|
private String mUnFoldedLabel;
|
||||||
|
private boolean mInitializeFolded;
|
||||||
|
|
||||||
public FoldableLinearLayout(Context context) {
|
public FoldableLinearLayout(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@@ -84,6 +85,7 @@ public class FoldableLinearLayout extends LinearLayout {
|
|||||||
R.styleable.FoldableLinearLayout, 0, 0);
|
R.styleable.FoldableLinearLayout, 0, 0);
|
||||||
mFoldedLabel = a.getString(R.styleable.FoldableLinearLayout_foldedLabel);
|
mFoldedLabel = a.getString(R.styleable.FoldableLinearLayout_foldedLabel);
|
||||||
mUnFoldedLabel = a.getString(R.styleable.FoldableLinearLayout_unFoldedLabel);
|
mUnFoldedLabel = a.getString(R.styleable.FoldableLinearLayout_unFoldedLabel);
|
||||||
|
mInitializeFolded = a.getBoolean(R.styleable.FoldableLinearLayout_initializeFolded, true);
|
||||||
a.recycle();
|
a.recycle();
|
||||||
}
|
}
|
||||||
// If any attribute isn't found then set a default one
|
// If any attribute isn't found then set a default one
|
||||||
@@ -102,6 +104,10 @@ public class FoldableLinearLayout extends LinearLayout {
|
|||||||
|
|
||||||
initialiseInnerViews();
|
initialiseInnerViews();
|
||||||
|
|
||||||
|
if (!mInitializeFolded) {
|
||||||
|
toggleFolded();
|
||||||
|
}
|
||||||
|
|
||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,6 +155,13 @@ public class FoldableLinearLayout extends LinearLayout {
|
|||||||
foldableControl.setOnClickListener(new View.OnClickListener() {
|
foldableControl.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
toggleFolded();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void toggleFolded() {
|
||||||
mFolded = !mFolded;
|
mFolded = !mFolded;
|
||||||
if (mFolded) {
|
if (mFolded) {
|
||||||
mFoldableIcon.setImageResource(R.drawable.ic_expand_less_black_24dp);
|
mFoldableIcon.setImageResource(R.drawable.ic_expand_less_black_24dp);
|
||||||
@@ -181,9 +194,6 @@ public class FoldableLinearLayout extends LinearLayout {
|
|||||||
mFoldableTextView.setText(mFoldedLabel);
|
mFoldableTextView.setText(mFoldedLabel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds provided child view to foldableContainer View
|
* Adds provided child view to foldableContainer View
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
<declare-styleable name="FoldableLinearLayout">
|
<declare-styleable name="FoldableLinearLayout">
|
||||||
<attr name="foldedLabel" format="string" />
|
<attr name="foldedLabel" format="string" />
|
||||||
<attr name="unFoldedLabel" format="string" />
|
<attr name="unFoldedLabel" format="string" />
|
||||||
|
<attr name="initializeFolded" format="boolean" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<!-- Taken from Matt Allen Password Strength View
|
<!-- Taken from Matt Allen Password Strength View
|
||||||
|
|||||||
Reference in New Issue
Block a user