I try to create My own PinView.i created it but i have one problem.i try to explain my problem i created four textviews and added it in Linearlayout and this linearlayout added my container (layout witch i have my xml file).Now i want to get my childview from my fontainer.this is a sturcure my views
<container>
<wapContainer>
<Textview>
</Textview>
</wapContainer>
<container>
this is a my source
private void addView( final LinearLayout childView) {
// Add a digit view for each digit
inputValue.setBackgroundColor(getResources().getColor(android.R.color.transparent));
inputValue.setTextColor(getResources().getColor(android.R.color.transparent));
inputValue.setCursorVisible(false);
inputValue.setFilters(new InputFilter[]{new InputFilter.LengthFilter(mDigits)});
inputValue.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
inputValue.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
inputValue.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
// Update the selected state of the views
int length = inputValue.getText().length();
for (int i = 0; i < mDigits; i++) {
childView.getChildAt(i).setSelected(hasFocus && (mAccentType == ACCENT_ALL ||
(mAccentType == ACCENT_CHARACTER && (i == length ||
(i == mDigits - 1 && length == mDigits)))));
}
if (mOnFocusChangeListener != null) {
mOnFocusChangeListener.onFocusChange(CustomPinConfirmView.this, hasFocus);
}
}
});
for (int i = 0; i < mDigits; i++) {
DigitView digitView = new DigitView(getContext());
digitView.setLayoutParams(new LinearLayout.LayoutParams(valueInPixels, valueInPixels));
wapContainer = new LinearLayout(mContext);
wapContainer.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 5f / mDigits));
wapContainer.setGravity(Gravity.CENTER);
digitView.setTextColor(Color.WHITE);
digitView.setTextSize(pxFromDp(14, mContext));
digitView.setGravity(Gravity.CENTER);
mWidgets.add(digitView);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
digitView.setElevation(mDigitElevation);
}
wapContainer.addView(digitView);
childView.addView(wapContainer);
}
inputValue.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
int length = s.length();
for (int i = 0; i < mDigits; i++) {
if (s.length() > i) {
String mask = mMask == null || mMask.length() == 0 ?
String.valueOf(s.charAt(i)) : mMask;
if(childView.getChildAt(i) instanceof LinearLayout)
{
Log.e("Taggggggggggg",childView.getChildCount() +"");
Log.e("Taggggggggggg",childView.getClass().getSimpleName() + " " + childView.getClass().getSimpleName().length());
//((TextView) childView.getChildAt(i)).setText(mask);
}
}
else {
}
}
}
});
}
As you can See i can Log my wapContainer witch i created programmatically but i can't(i don't know) how to get wapContainer 's childView(my textviews) if anyone knows solution please help me thanks everyone
Usual way to do this is to set an ID to your textView.
Then use findViewById() to get the reference to it.
Hope this helps.