У меня есть типичный сценарий - операция master (ListFragment), которая активирует детальную активность при щелчке элемента. Все работает нормально.Почему применение темы к действию вызывает следующий сбой?
Теперь я хотел сделать весь текст в подробном представлении (красном/зеленом) на основе программного условия. Я понимаю, что способ сделать это с темой
Таким образом, в значениях-V14 (мой Samsung Примечание 1 Устройство работает под управлением Android 4.1), styles.xml
<style name="ExpensesStyle" parent="@android:style/TextAppearance.Medium">
<item name="android:textColor">@color/expense_background</item>
</style>
colors.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<color name="credit_background">#6DA000</color>
<color name="expense_background">#D30A0A</color>
</resources>
AndroidManifest.xml
<activity
android:name="com.app.transactions.TransactionActivity"
android:label="@string/app_name"
android:theme="@style/ExpensesStyle">
</activity>
андроид: атрибут тема вызывает следующий гр сыпь. Применение стиля к отдельному представлению (EditText) работает правильно.
W/ResourceType(30089): Too many attribute references, stopped at: 0x01010099
W/ResourceType(30089): Too many attribute references, stopped at: 0x0101009a
W/ResourceType(30089): Too many attribute references, stopped at: 0x0101009b
E/com.app.TranAct(30089): Error in creation Tran Detail Activity
E/com.app.TranAct(30089): android.view.InflateException: Binary XML file line #30: Error inflating class <unknown>
E/com.app.TranAct(30089): at android.view.LayoutInflater.createView(LayoutInflater.java:619)
E/com.app.TranAct(30089): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:693)
E/com.app.TranAct(30089): at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
E/com.app.TranAct(30089): at android.view.LayoutInflater.rInflate(LayoutInflater.java:760)
E/com.app.TranAct(30089): at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
E/com.app.TranAct(30089): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
E/com.app.TranAct(30089): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
E/com.app.TranAct(30089): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:3163)
E/com.app.TranAct(30089): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3223)
E/com.app.TranAct(30089): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:312)
E/com.app.TranAct(30089): at android.app.Activity.setContentView(Activity.java:1924)
E/com.app.TranAct(30089): at com.app.transactions.TransactionActivity.onCreate(TransactionActivity.java:30)
Activity.onCreate
@Override
protected void onCreate(Bundle instanceState) {
try {
super.onCreate(instanceState);
setContentView(R.layout.activity_simple);
Intent intent = getIntent();
long transId = intent.getLongExtra(EXTRA_TRAN_ID, 0);
boolean isExpense = intent.getBooleanExtra(EXTRA_TRAN_IS_EXPENSE, true);
if(instanceState != null)
return;
Fragment frag = TransactionDetailFragment.newInstance(isExpense ? new ExpenseFragment(): new CreditFragment(),
transId, this);
getSupportFragmentManager().beginTransaction()
.add(R.id.simple_fragment_container, frag)
.commit();
} catch (Exception e) {
Log.e(TAG, "Error in creation Tran Detail Activity", e);
}
}
layout.activity_simple простой framelayout с заполнителем для фрагмента.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/simple_fragment_container" />
Линия 30 макета фрагмента содержит
<TextView
style="?android:listSeparatorTextViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/label_category" />
Можете ли вы выслать код активности? – crazyPixel
Возможно, макет, который вы используете в своей деятельности? – Blackbelt
@crazyPixel какой-либо конкретный метод? – Gishu