2016-12-26 12 views
0

У меня есть активность и динамически добавляются некоторые виды на нее. textcolor и colorfilter динамических edittexts различны, и я смущен почему? и мой флажок имеет ту же проблему. любой может помочь?TextColor и другие изменения по динамическому добавлению вида

<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_height="match_parent" 
android:layout_width="match_parent" 
app:cardBackgroundColor="@color/cardview_light_background" 
android:layout_marginTop="5dp" 
android:layout_marginRight="5dp" 
android:layout_marginLeft="5dp"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="right|center_vertical" 
     android:id="@+id/txtSearchSpecialAttrTitle" 
     android:padding="5dp"/> 
    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/SearchSpecialAttrEditText" 
     android:gravity="right|center_vertical" 
     android:inputType="number" 
     android:theme="@style/Theme.App.Base" 
     /> 
</LinearLayout> 

</android.support.v7.widget.CardView> 

и так я добавляю это в свою деятельность.

LinearLayout llSpecialAttribsContainer = (LinearLayout) activityWeakReference.get().findViewById(R.id.llSearchSpecialAttributesContainer); 
CardView cardView = (CardView) Global.inflater.inflate(R.layout.search_int_field_schema, llSpecialAttribsContainer, false); 
           TextView txtTitle = (TextView) cardView.findViewById(R.id.txtSearchSpecialAttrTitle); 
           txtTitle.setText(specialAttrib.persianFieldName); 

           EditText editText = (EditText) cardView.findViewById(R.id.SearchSpecialAttrEditText); 
           editText.getBackground().setColorFilter(Global.appContext.getResources().getColor(R.color.appBarColor), PorterDuff.Mode.SRC_IN); 
           editText.setTag(specialAttrib.fieldName); 

           llSpecialAttribsContainer.addView(cardView); 

любая помощь ???

Полный XML Добавлена ​​

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:layout_gravity="center"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:layout_gravity="center"> 
    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="5dp" 
     android:layout_marginRight="5dp" 
     android:layout_marginLeft="5dp"> 
    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:padding="10dp" 
     android:text="فیلتر جستجو" /> 
    </android.support.v7.widget.CardView> 

    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="5dp" 
     android:layout_marginRight="5dp" 
     android:layout_marginLeft="5dp"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:animateLayoutChanges="true" 
     android:padding="10dp"> 

     <Spinner 
      android:id="@+id/activitySearch_Spinner_Parent" 
      android:layout_width="300dp" 
      android:layout_height="50dp" 
      android:layout_gravity="center"> 
      <requestFocus/> 
     </Spinner> 

     <Spinner 
      android:id="@+id/activitySearch_Spinner_Child" 
      android:layout_width="300dp" 
      android:layout_height="50dp" 
      android:visibility="gone" 
      android:layout_gravity="center" 
      android:layout_marginTop="5dp"/> 

     <Spinner 
      android:id="@+id/activitySearch_Spinner_GrandChild" 
      android:layout_width="300dp" 
      android:layout_height="50dp" 
      android:visibility="gone" 
      android:layout_gravity="center" 
      android:layout_marginTop="5dp" 
      android:layout_marginBottom="5dp"/> 
    </LinearLayout> 

    </android.support.v7.widget.CardView> 

    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="5dp" 
     android:layout_marginRight="5dp" 
     android:layout_marginLeft="5dp"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="60dp" 
     android:orientation="horizontal" 
     android:padding="5dp"> 

     <EditText 
      android:id="@+id/edtSearchMaxPrice" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_marginRight="5dp" 
      android:layout_weight=".35" 
      android:inputType="number" 
      android:layout_gravity="center"/> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_marginRight="5dp" 
      android:layout_weight=".15" 
      android:gravity="center" 
      android:text=" تا " /> 

     <EditText 
      android:id="@+id/edtSearchMinPrice" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_marginRight="5dp" 
      android:layout_weight=".35" 
      android:inputType="number" 
      android:gravity="center"> 
      <requestFocus/> 
     </EditText> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_marginRight="5dp" 
      android:layout_weight=".15" 
      android:gravity="center" 
      android:text="قیمت از " 
      android:layout_gravity="center"/> 

    </LinearLayout> 

    </android.support.v7.widget.CardView> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/llSearchSpecialAttributesContainer" 
     android:orientation="vertical" 
     android:animateLayoutChanges="true" 
     android:background="@color/cardview_light_background"> 

    </LinearLayout> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:weightSum="1"> 
     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_weight=".5" 
      android:layout_height="match_parent"> 
      <android.support.v7.widget.AppCompatButton 
       android:id="@+id/btnSubmitSearch" 
       style="?attr/buttonBarButtonStyle" 
       android:layout_width="0dp" 
       android:layout_weight=".6" 
       android:layout_height="70dp" 
       android:text="اعمال فیلتر" 
       android:textColor="@color/appBarColor" 
       android:layout_margin="5dp" 
       android:gravity="center"/> 

      <android.support.v7.widget.AppCompatButton 
       android:id="@+id/btnCancelSearch" 
       style="?attr/buttonBarButtonStyle" 
       android:layout_width="0dp" 
       android:layout_weight=".4" 
       android:layout_height="70dp" 
       android:text="لغو" 
       android:textColor="@color/appBarColor" 
       android:layout_marginLeft="0dp" 
       android:layout_marginTop="5dp" 
       android:layout_marginBottom="5dp" 
       android:layout_marginRight="5dp" 
       android:gravity="center" /> 

     </LinearLayout> 



    </LinearLayout> 
</LinearLayout> 

+0

постом полного XML файл, пожалуйста –

+0

полного XML размещен @SaurabhBhandari – Hamed

+0

U необходимо предоставить идентификатор для вашего линейного макета, в котором вы хотите добавить динамически EditText. И получите ссылку в своем классе. для более ifo следуйте этому http://stackoverflow.com/questions/10666019/how-to-add-views-dynamically-to-a-relativelayout-already-declared-in-the-xml-lay –

ответ

0

Я должен получить активность инфлятором, но я получаю инфлятором из контекста приложения и вызвать динамические представления не имеют тему приложения!

С наилучшими пожеланиями