package ch.pizzalink.android.view; import android.content.Context; import android.content.res.TypedArray; import android.support.v4.content.ContextCompat; import android.util.AttributeSet; import android.view.View; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; import ch.pizzalink.android.R; import ch.pizzalink.android.activity.BaseActivity; /** * Created by cimenmus on 26.10.2017. */ public class PizzalinkDropdownView extends LinearLayout { private View rootView; private TextView hintTextView; private TextView textview; private RelativeLayout bottomLineLayout; private String hint; private String dropdownTheme; public PizzalinkDropdownView(Context context) { super(context); init(context); } public PizzalinkDropdownView(Context context, AttributeSet attrs) { super(context, attrs); TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.PizzalinkDropdownView, 0, 0); try { hint = a.getString(R.styleable.PizzalinkDropdownView_dropdownHintView); dropdownTheme = a.getString(R.styleable.PizzalinkDropdownView_dropdownTheme); } finally { a.recycle(); } init(context); } private void init(Context context) { rootView = (View) inflate(context, R.layout.layout_pizzalink_drowdown_view, this); hintTextView = (TextView) rootView.findViewById(R.id.hintTextView); textview = (TextView) rootView.findViewById(R.id.textview); bottomLineLayout = (RelativeLayout) rootView.findViewById(R.id.bottomLineLayout); hintTextView.setText(hint); if(dropdownTheme != null && dropdownTheme.equals("navy")){ int navyColor = ContextCompat.getColor(BaseActivity.currentActivity, R.color.navigation_drawer_background); hintTextView.setTextColor(navyColor); textview.setTextColor(navyColor); bottomLineLayout.setBackgroundColor(navyColor); } } public boolean isEmpty(){ return hintTextView.getText().toString().isEmpty(); } public String getText(){ return hintTextView.getText().toString(); } public void setText(String text){ textview.setText(text); } }