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