CustomView don't show in design mode - android

I have a CustomView extend from RelativeLayout.
I Use this CustomView in layout file but Android Studio in design mode not showing the CustomView. what is problem?
koala_appbar.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:layout_gravity="top"
tools:context=".activity.basic.BaseActivity">
<ImageView
android:id="#+id/appbar_imgLogo"
android:layout_width="#dimen/appBar_iconWidth"
android:layout_height="#dimen/appBar_iconHeight"
android:src="#drawable/logo"
android:layout_marginTop="#dimen/appBar_iconTopMargin"
android:layout_marginLeft="#dimen/appBar_iconLeftMargin"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/appbar_height"
android:orientation="horizontal"
android:layoutDirection="ltr"
>
<koala.android.customer.views.widget.CustomTextView
android:id="#+id/appBar_txtTitle"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center|right"
android:text="#string/app_name_persian"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/TextSize_large"
app:tvCustomFont="#string/baseFont"
/>
<koala.android.customer.views.widget.CustomImageView
android:id="#+id/appBar_imgBack"
android:layout_width="#dimen/appbar_height"
android:layout_height="match_parent"
app:srcCompat="#drawable/ic_arrow_right"
app:ivDrawableTint="#color/colorPrimary"
android:padding="#dimen/appBar_backPadding"
/>
</LinearLayout>
</RelativeLayout>
KoalaAppBar.java:
public class KoalaAppBar extends RelativeLayout {
private static final String DEFAULT_TITLE = "default";
private static final int DEFAULT_TITLE_COLOR = ResourcesCompat.getColor(AppController.getContext().getResources(), R.color.colorPrimary , null);
private static final float DEFAULT_TITLE_FONT_SIZE = AppController.getContext().getResources().getDimension(R.dimen.TextSize_small);
protected CustomTextView txtTitle;
protected CustomImageView imgBack;
protected ImageView imgLogo;
public KoalaAppBar(Context context) {
super(context);
init(context , null);
}
public KoalaAppBar(Context context, #Nullable AttributeSet attrs) {
super(context, attrs);
init(context , attrs);
}
public KoalaAppBar(Context context, #Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context , attrs);
}
#RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public KoalaAppBar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(context, attrs);
}
private void init(Context context, AttributeSet attrs) {
if(context != null){
findViews(context);
}
if(attrs != null){
initAttribute(context,attrs);
}
}
private void initAttribute(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.KoalaAppBar);
String title = a.getString(R.styleable.KoalaAppBar_appTitle);
if(title == null || title.isEmpty()){
title = DEFAULT_TITLE;
}
int titleColor = a.getColor(R.styleable.KoalaAppBar_appTitleColor, DEFAULT_TITLE_COLOR);
float fontSize = a.getDimension(R.styleable.KoalaAppBar_appTitleFontSize, DEFAULT_TITLE_FONT_SIZE);
boolean logoVisibility = a.getBoolean(R.styleable.KoalaAppBar_appLogoVisibility , true);
initTitle(title , titleColor , fontSize);
initLogo(logoVisibility);
a.recycle();
}
private void initLogo(boolean logoVisibility) {
if(logoVisibility){
this.imgLogo.setVisibility(VISIBLE);
}else{
this.imgLogo.setVisibility(GONE);
}
}
private void initTitle(String title, int titleColor, float fontSize) {
this.txtTitle.setText(title);
this.txtTitle.setTextColor(titleColor);
this.txtTitle.setTextSize(fontSize);
}
private void findViews(Context context) {
View rootView =
LayoutInflater.from(context).inflate(
R.layout.koala_appbar,
this,
true
);
this.txtTitle = rootView.findViewById(R.id.appBar_txtTitle);
this.imgBack = rootView.findViewById(R.id.appBar_imgBack);
this.imgLogo = rootView.findViewById(R.id.appbar_imgLogo);
}
}

Related

Create View By "inflate" extends RelativeLayout,But was blank when using

I Dim a view by inflate the layout, Code like this:
public class MenuItemView extends RelativeLayout {
private Context context;
TextView tv_title;
String title = "";
TextView tv_content;
String content = "";
TextView tv_guid;
String guid = "";
ImageView iv_divider;
ImageView iv_arrow;
RelativeLayout rl_main;
public MenuItemView(Context context) {
super(context);
initView(context, null);
}
public MenuItemView(Context context, AttributeSet attrs) {
super(context, attrs);
initView(context, attrs);
}
public MenuItemView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initView(context, attrs);
}
public MenuItemView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
initView(context, attrs);
}
#Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
for (int i = 0; i < getChildCount(); i++) {
getChildAt(i).layout(l, t, r, b);
}
}
private void initView(Context context, AttributeSet attrs) {
this.context = context;
inflate(context, R.layout.menu_item_view_layout, this);
tv_title = (TextView) findViewById(R.id.tv_title);
tv_content = (TextView) findViewById(R.id.tv_content);
tv_guid = (TextView) findViewById(R.id.tv_guid);
iv_arrow = (ImageView) findViewById(R.id.iv_arrow);
iv_divider = (ImageView) findViewById(R.id.iv_divider);
rl_main = (RelativeLayout) findViewById(R.id.rl_main);
//Default
if (attrs != null) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MenuItemView);
title = a.getString(R.styleable.MenuItemView_menu_title);
content = a.getString(R.styleable.MenuItemView_menu_content);
guid = a.getString(R.styleable.MenuItemView_menu_guid);
a.recycle();
}
//
tv_title.setText(title);
tv_content.setText(content);
tv_guid.setText(guid);
}
#Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
private int getpx(int dp) {
return (int) (context.getResources().getDisplayMetrics().density * dp + 0.5f);
}
}
when I use it in layout.like this
while is performed right, but when I use it in times, like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<setmenu.smzdm.com.menuitemview.MenuItemView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/menu_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:menu_content="Content"
app:menu_guid="Guid"
app:menu_title="Title" />
<setmenu.smzdm.com.menuitemview.MenuItemView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/menu_item2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:menu_content="Content"
app:menu_guid="Guid"
app:menu_title="Title" />
<setmenu.smzdm.com.menuitemview.MenuItemView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/menu_item3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:menu_content="Content"
app:menu_guid="Guid"
app:menu_title="Title" />
</LinearLayout>
It can just show one view,like:
when it run on mobile, it is also just can show one view in layout.
Your view you inflate is not added to your customer view. You should fix:
View view = inflate(context, R.layout.menu_item_view_layout, this);
tv_title = (TextView) view.findViewById(R.id.tv_title);
tv_content = (TextView) view.findViewById(R.id.tv_content);
tv_guid = (TextView) view.findViewById(R.id.tv_guid);
iv_arrow = (ImageView) view.findViewById(R.id.iv_arrow);
iv_divider = (ImageView) view.findViewById(R.id.iv_divider);
rl_main = (RelativeLayout) view.findViewById(R.id.rl_main);
// your code
// and last, you have to add view to customeView
addView(view);

programmatically change color of Switch

I am trying to create a simple Custom Switch Widget that listens to changes in value of a certain key in SharedPreferences. Below is my code:
public class CustomSwitch extends SwitchCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
private static final String TAG = CustomSwitch.class.getSimpleName();
private boolean isSwitchTintColorPrimary;
public CustomSwitch(Context context) {
this(context, null);
}
public CustomSwitch(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public CustomSwitch(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initializeView(context, attrs);
}
private void initializeView(Context context, AttributeSet attrs) {
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.CustomSwitch, 0, 0);
try {
isSwitchTintColorPrimary = ta.getBoolean(R.styleable.CustomSwitch_tintColorPrimary, false);
} finally {
ta.recycle();
}
applyTheme();
}
#Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
registerThemeChangeListener();
}
private void registerThemeChangeListener() {
if (getContext() != null)
ColoriyoPreference.getSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
}
#Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
unRegisterThemeChangeListener();
}
private void unRegisterThemeChangeListener() {
if (getContext() != null)
ColoriyoPreference.getSharedPreferences(getContext()).unregisterOnSharedPreferenceChangeListener(this);
}
private void applyTheme() {
ColorStateList thumbStates = new ColorStateList(
new int[][]{
{android.R.attr.state_checked, android.R.attr.state_enabled},
{-android.R.attr.state_checked, android.R.attr.state_enabled},
{}
},
new int[]{
isSwitchTintColorPrimary ? ColoriyoPreference.getColor(getContext()) : ContextCompat.getColor(getContext(), R.color.colorPrimary),
ContextCompat.getColor(getContext(), R.color.grey_50),
ContextCompat.getColor(getContext(), R.color.grey_50)
}
);
setThumbTintList(thumbStates);
ColorStateList trackStates = new ColorStateList(
new int[][]{
new int[]{-android.R.attr.state_enabled},
new int[]{}
},
new int[]{
Color.GRAY,
Color.LTGRAY
}
);
setTrackTintList(trackStates);
setTrackTintMode(PorterDuff.Mode.OVERLAY);
}
#Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals(PREFERENCE_KEY_COLOR)) {
applyTheme();
}
}
}
And in layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.chintansoni.android.themedemo.MainActivity"
tools:showIn="#layout/activity_main">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.chintansoni.android.themedemo.customview.themeview.CustomTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView textColor"
app:textColorPrimary="true" />
<com.chintansoni.android.themedemo.customview.themeview.CustomButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button Background"
app:backgroundColorPrimary="true" />
<com.chintansoni.android.themedemo.customview.themeview.CustomSwitch
android:id="#+id/switch_main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textOff="Off"
android:textOn="On"
app:tintColorPrimary="true" />
</LinearLayout>
<uz.shift.colorpicker.LineColorPicker
android:id="#+id/picker"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_margin="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:orientation="horizontal" />
</android.support.constraint.ConstraintLayout>
But my view is not getting rendered in UI. Also, I wonder if this code will listen to color change in preference and reflect the color change in runtime?
Any suggestion?
The only thing I was missing:
public CustomSwitch(Context context, AttributeSet attrs) {
this(context, attrs, R.attr.switchStyle); // <--- passing default Style Attribute
}
My improved class is as below:
public class CustomSwitch extends SwitchCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
private boolean isSwitchTintColorPrimary;
public CustomSwitch(Context context) {
this(context, null);
}
public CustomSwitch(Context context, AttributeSet attrs) {
this(context, attrs, R.attr.switchStyle);
}
public CustomSwitch(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initializeView(context, attrs);
}
private void initializeView(Context context, AttributeSet attrs) {
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.CustomSwitch, 0, 0);
try {
isSwitchTintColorPrimary = ta.getBoolean(R.styleable.CustomSwitch_tintColorPrimary, false);
} finally {
ta.recycle();
}
applyTheme();
}
#Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
registerThemeChangeListener();
}
private void registerThemeChangeListener() {
if (getContext() != null)
ColoriyoPreference.getSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
}
#Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
unRegisterThemeChangeListener();
}
private void unRegisterThemeChangeListener() {
if (getContext() != null)
ColoriyoPreference.getSharedPreferences(getContext()).unregisterOnSharedPreferenceChangeListener(this);
}
private void applyTheme() {
ColorStateList thumbStates = new ColorStateList(
new int[][]{
{android.R.attr.state_checked, android.R.attr.state_enabled},
{-android.R.attr.state_checked, android.R.attr.state_enabled},
{}
},
new int[]{
isSwitchTintColorPrimary ? ColoriyoPreference.getColor(getContext()) : ContextCompat.getColor(getContext(), R.color.colorPrimary),
ContextCompat.getColor(getContext(), R.color.grey_50),
ContextCompat.getColor(getContext(), R.color.grey_50)
}
);
setThumbTintList(thumbStates);
ColorStateList trackStates = new ColorStateList(
new int[][]{
new int[]{android.R.attr.state_enabled},
new int[]{-android.R.attr.state_enabled}
},
new int[]{
Color.LTGRAY,
Color.GRAY,
Color.LTGRAY
}
);
setTrackTintList(trackStates);
}
#Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals(ColoriyoPreference.PREFERENCE_KEY_COLOR)) {
applyTheme();
}
}
}

Android custom AutoCompleteTextView doesn't appear after hiding

I create an autoCompleteTextView as below Layout and Java class :
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/autoCompleteTextViewGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:minHeight="#dimen/component_height">
<android.support.design.widget.TextInputLayout
android:id="#+id/textInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:animateLayoutChanges="true">
<AutoCompleteTextView
android:id="#+id/autoCompleteTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:completionThreshold="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<android.support.v4.widget.ContentLoadingProgressBar
android:id="#+id/progressBar"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:indeterminate="true"
android:indeterminateDrawable="#anim/anim_indeterminate_mini"
android:interpolator="#anim/anim_progress_interpolator"
android:visibility="visible" />
</FrameLayout>
and Java class is :
public class MAutoCompleteText extends LinearLayout {
AutoCompleteTextView autoCompleteTextView;
ContentLoadingProgressBar progressBar;
TextInputLayout textInputLayout;
ViewGroup autoCompleteTextViewGroup;
public MAutoCompleteText(Context context) {
super(context);
init(context);
}
public MAutoCompleteText(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public MAutoCompleteText(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
#TargetApi(21)
public MAutoCompleteText(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(context);
}
private void init(Context context) {
inflate(context, R.layout.layout_auto_complete_text, this);
autoCompleteTextViewGroup = (ViewGroup) findViewById(R.id.autoCompleteTextViewGroup);
textInputLayout = (TextInputLayout) findViewById(R.id.textInputLayout);
autoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView);
progressBar = (ContentLoadingProgressBar) findViewById(R.id.progressBar);
}
public void setAdapter(ArrayAdapter<String> adapter) {
autoCompleteTextView.setAdapter(adapter);
}
public String getText() {
return autoCompleteTextView.getText().toString();
}
public void setErrorEnabled(boolean status) {
textInputLayout.setErrorEnabled(status);
}
public void setError(int errorId) {
textInputLayout.setError(getContext().getString(errorId));
}
public int getVisibility() {
return autoCompleteTextViewGroup.getVisibility();
}
public void setVisibility(int visibility) {
autoCompleteTextViewGroup.setVisibility(visibility);
autoCompleteTextViewGroup.setMinimumHeight(R.dimen.component_height);
}
public void setProgressBarVisibility(int visibility) {
progressBar.setVisibility(visibility);
}
public MAutoCompleteText setHint(int hintId) {
autoCompleteTextView.setHint(hintId);
return this;
}
public void setImeOption(int imeOption) {
autoCompleteTextView.setImeOptions(imeOption);
}
}
Everything work OK. I setVisibility(GONE) and my component hide from UI,
but when I use setVisibility(VISIBLE) doesn't happen any thing !!!!
How can I display my component programmatically?
I found answer of my problem , at least it works now ... :)
I change setVisibility to below code :
public void setVisibility(int visibility) {
autoCompleteTextViewGroup.setVisibility(visibility);
if (visibility == View.VISIBLE) {
textInputLayout.setVisibility(visibility);
autoCompleteTextView.setVisibility(visibility);
progressBar.setVisibility(visibility);
requestLayout();
}
}
In fact requestLayout(); reDraw layout of my component on UI again and it`s appear correctly .

Stroke in textview text android?

I need to style the text for textview as per the below image
The font being used is CARTER ONE font
This is my textview class
public class CustomTextViewCarter extends TextView {
private static Typeface mTypeface;
public CustomTextViewCarter(final Context context) {
this(context, null);
}
public CustomTextViewCarter(final Context context, final AttributeSet attrs) {
this(context, attrs, 0);
}
public CustomTextViewCarter(final Context context, final AttributeSet attrs, final int defStyle) {
super(context, attrs, defStyle);
if (!isInEditMode()) {
if (mTypeface == null) {
mTypeface = Typeface.createFromAsset(context.getResources().getAssets(), "carter_one.ttf");
}
setTypeface(mTypeface);
}
}
}
But the the same kind of text doesn't appear. How can it be done?
Use this code for show custom TextView
Step-1:
CustomTextView.java
public class CustomTextView extends TextView {
private static final String TAG = "TextView";
public CustomTextView(Context context) {
super(context);
}
public CustomTextView(Context context, AttributeSet attrs) {
super(context, attrs);
setCustomFont(context, attrs);
}
public CustomTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setCustomFont(context, attrs);
}
private void setCustomFont(Context ctx, AttributeSet attrs) {
TypedArray a = ctx.obtainStyledAttributes(attrs,R.styleable.CustomTV);
String customFont = a.getString(R.styleable.CustomTV_customFont);
setCustomFont(ctx, customFont);
a.recycle();
}
public boolean setCustomFont(Context ctx, String asset) {
Typeface tf = null;
try {
tf = Typeface.createFromAsset(ctx.getAssets(), asset);
} catch (Exception e) {
Log.e(TAG, "Could not get typeface: "+e.getMessage());
return false;
}
setTypeface(tf);
return true;
}
}
Step-2:
After that write below code in your styles.xml file
<declare-styleable name="CustomTV">
<attr name="customFont" format="string"></attr>
</declare-styleable>
Step-3:
Use CustomTextView in your xml file
Here com.app.demo is my package name.. use your package name instead of that,
<com.app.demo.CustomTextView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="hello"
android:textColor="#color/text"
android:textStyle="bold"
app:customFont="carter_one.ttf" />
Try this.
You can set ttf by making your own textview implementation.
It will works above API 15 (Ice cream sandwich).
https://stackoverflow.com/a/5185587/850347
<com.lht.ui.MyTextView
android:text="Hello friends"
lht:ttf_name="ITCBLKAD.TTF"
/>

textView.setText is not working in compound view

textView.setText is not working properly in a compound view.
Means Both hello and jack are appearing...
and jack is displayed below layout not appearing if I put some background color,...
Could somebody help... Thanks and regards...
Here is my code...
Layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/chatLayout"
android:layout_width="300dp"
android:layout_height="400dp"
>
<TextView
android:id="#+id/chatNamed"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Hello"
android:textColor="#ffffff"
android:textSize="20dp"
android:textStyle="bold"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
/>
</RelativeLayout>
CompoundView.java
public class ChatCompoundView extends RelativeLayout {
private static TextView zoneName;
public ChatCompoundView(Context context) {
this(context, null);
setView();
}
public ChatCompoundView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
setView();
}
public ChatCompoundView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setView();
}
public void setView()
{
inflate(getContext(), R.layout.chat_layout, this);
zoneName = (TextView) findViewById(R.id.chatNamed);
}
zoneName.setText("jack");
}
try this..
LayoutInflater mInflater;
public ChatCompoundView (Context context) {
super(context);
mInflater = LayoutInflater.from(context);
setView();
}
setView():
public void setView(){
mInflater.inflate(R.layout.custom_view, this, true);
TextView zoneName = (TextView) findViewById(R.id.chatNamed);
zoneName .setText("jack");
}
Yeah Now I got the Answer... Actually my constructors are called with this(context),.. and I need to call super(context)...
Code Changed to
public ChatCompoundView(Context context) {
super(context);
setView();
}
public ChatCompoundView(Context context, AttributeSet attrs) {
super(context, attrs);
setView();
}
public ChatCompoundView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setView();
}

Categories

Resources