- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我想修改以下选项卡的文本颜色:(ACCUEIL 和 A LA UNE)(现在为黑色)。
我不知道该怎么做。
这是 FragmentActivity 的代码:
package com.app.myapp.MainFragment;
import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.TextView;
import com.app.myapp.R;
import com.app.myapp.activities.Recherche_act;
public class TabMainFragment extends FragmentActivity implements ActionBar.TabListener {
private ViewPager viewPager;
private TabMainFragmentAdapter mAdapter;
private ActionBar actionBar;
// Tab titles
private String[] tabs = { "ACCUEIL", "A LA UNE" };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Typeface parade = Typeface.createFromAsset(getAssets(), "fonts/parade.ttf");
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getActionBar().setCustomView(R.layout.actionbar);
TextView title = (TextView) findViewById(R.id.action_bar_title);
title.setTypeface(parade);
title.setTextSize(23);
title.setGravity(Gravity.CENTER_VERTICAL);
title.setTextColor(Color.WHITE);
setContentView(R.layout.main_tab_detail_frag);
//Typeface robotolight = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Light.ttf");
ActionBar bar = getActionBar();
bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#E64260")));
// Initilization
viewPager = (ViewPager) findViewById(R.id.pager);
actionBar = getActionBar();
mAdapter = new TabMainFragmentAdapter(getSupportFragmentManager());
viewPager.setAdapter(mAdapter);
actionBar.setHomeButtonEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Adding Tabs
for (String tab_name : tabs) {
actionBar.addTab(actionBar.newTab().setText(tab_name).setTabListener(this));
}
/**
* on swiping the viewpager make respective tab selected
* */
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
// on changing the page
// make respected tab selected
actionBar.setSelectedNavigationItem(position);
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}
@Override
public void onPageScrollStateChanged(int arg0) {
}
});
}
@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
}
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// on tab selected
// show respected fragment view
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu items for use in the action bar
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle presses on the action bar items
switch (item.getItemId()) {
case R.id.action_choix_categorie:
Intent myIntent = new Intent(TabMainFragment.this, Recherche_act.class);
TabMainFragment.this.startActivity(myIntent);
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
这是我的 AndroidManifest 的摘录:
<activity android:name="com.app.frisbeee.MainFragment.TabMainFragment"
android:theme="@style/Theme.Rosenormal" />
最后,我的 style.xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<!-- File created by the Android Action Bar Style Generator
Copyright (C) 2011 The Android Open Source Project
Copyright (C) 2012 readyState Software Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<style name="Theme.Rosenormal" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarItemBackground">@drawable/selectable_background_rosenormal</item>
<item name="android:popupMenuStyle">@style/PopupMenu.Rosenormal</item>
<item name="android:dropDownListViewStyle">@style/DropDownListView.Rosenormal</item>
<item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Rosenormal</item>
<item name="android:actionDropDownStyle">@style/DropDownNav.Rosenormal</item>
<item name="android:actionBarStyle">@style/ActionBar.Solid.Rosenormal</item>
<item name="android:actionModeBackground">@drawable/cab_background_top_rosenormal</item>
<item name="android:actionModeSplitBackground">@drawable/cab_background_bottom_rosenormal</item>
<item name="android:actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Rosenormal</item>
</style>
<style name="ActionBar.Solid.Rosenormal" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">@drawable/ab_solid_rosenormal</item>
<item name="android:backgroundStacked">@drawable/ab_stacked_solid_rosenormal</item>
<item name="android:backgroundSplit">@drawable/ab_bottom_solid_rosenormal</item>
<item name="android:progressBarStyle">@style/ProgressBar.Rosenormal</item>
</style>
<style name="ActionBar.Transparent.Rosenormal" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">@drawable/ab_transparent_rosenormal</item>
<item name="android:progressBarStyle">@style/ProgressBar.Rosenormal</item>
</style>
<style name="PopupMenu.Rosenormal" parent="@android:style/Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">@drawable/menu_dropdown_panel_rosenormal</item>
</style>
<style name="DropDownListView.Rosenormal" parent="@android:style/Widget.Holo.Light.ListView.DropDown">
<item name="android:listSelector">@drawable/selectable_background_rosenormal</item>
</style>
<style name="ActionBarTabStyle.Rosenormal" parent="@android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:background">@drawable/tab_indicator_ab_rosenormal</item>
</style>
<style name="DropDownNav.Rosenormal" parent="@android:style/Widget.Holo.Light.Spinner">
<item name="android:background">@drawable/spinner_background_ab_rosenormal</item>
<item name="android:popupBackground">@drawable/menu_dropdown_panel_rosenormal</item>
<item name="android:dropDownSelector">@drawable/selectable_background_rosenormal</item>
</style>
<style name="ProgressBar.Rosenormal" parent="@android:style/Widget.Holo.Light.ProgressBar.Horizontal">
<item name="android:progressDrawable">@drawable/progress_horizontal_rosenormal</item>
</style>
<style name="ActionButton.CloseMode.Rosenormal" parent="@android:style/Widget.Holo.Light.ActionButton.CloseMode">
<item name="android:background">@drawable/btn_cab_done_rosenormal</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Rosenormal.Widget" parent="@android:style/Theme.Holo">
<item name="android:popupMenuStyle">@style/PopupMenu.Rosenormal</item>
<item name="android:dropDownListViewStyle">@style/DropDownListView.Rosenormal</item>
</style>
</resources>
最佳答案
为此,您需要在自定义主题中覆盖 android:actionBarTabTextStyle
。例如:
<style name="Theme.Rosenormal" parent="@android:style/Theme.Holo.Light">
... same as before ...
<item name="android:actionBarTabTextStyle">@style/ActionBarTabText.Rosenormal</item>
</style>
然后:
<style name="ActionBarTabText.Rosenormal" parent="@android:style/Widget.Holo.Light.ActionBar.TabText">
<item name="android:textColor">#f00</item>
</style>
您可能想要使用颜色资源,#f00
值只是一个示例。
关于安卓 : Change text color of Tab in FragmentActivity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24466237/
我遇到了一个无法用应用程序的抽屉导航解决的问题。抽屉导航中的链接之一是打开 FragmentActivity(其中包含 ViewPager)。其他链接是 fragment 。现在我已将其设置为启动该
除了使用 Intents 启动方法外,还有其他方法可以调用 FragmentActivity 中的方法吗?有人可以帮忙吗? 代码如下: class MainActiviy extends Ac
在我的应用程序中,它们不是 FragmentActivity.java,但崩溃报告给了我以下错误 Fatal Exception: android.content.ActivityNotFoundEx
我是 Java 和 Android 的初学者,我认为这更像是一个 Java 问题,因为它在 Android 中表现出来。 我正在使用 Android 支持包 (android.support.v4.a
我有两项 Activity : MainActivity,它扩展了 FragmentActivity 并具有 ViewActivity,它只是一个 Activity,以 MainActivity 作为
我对 FragmentActivity 类有疑问当我导入包时: import android.support.v4.app.FragmentActivity; 当我将其放入代码中时,导入 Fragme
今天我尝试创建一个带有 fragment Activity 的项目。我有一个 MainActivity 范围 FragmentActivity。 MainActvity 有布局。 activity_m
我在使用 FragmentActivity 和 SupportMapFragment 时遇到了一些问题。 map 的缩放比例很不稳定。这是代码: public class GoogleMapActiv
Activity 在导入 FragmentActivity 时显示错误。 import android.support.v4.app.FragmentActivity; import andr
我的代码中有一个具有 ListView 的 Activity ,我通过适配器类控制此 ListView 。每个 ListView 中都有一个 TextView,我想通过单击每个项目(TextView)
我正在尝试创建一个使用 fragment 的应用程序,但是当我尝试在 FragmentActivity 中显示一个 Fragment 时,操作栏没有出现。 fragment Activity 类: p
我可以使用下面的代码转换到 Fragment 类,但是如何使用相同的代码转换到 FragmentActivity。 FragmentActivity activity = new ABC(); //
您好,您可以在这里查看我的代码。我的问题是:使用这段代码,我的 EditText 和我的 Button 字段为空,所以我无法对它们执行任何操作。 请你帮我访问这个按钮。对于由 eclipse 自动生成
我尝试将 Android 兼容性库(或现在称为支持库)v4 用于 pre-honeycomb android 设备。我明白,我应该使用 FragmentActivity 类,而不是使用 Fragmen
我的主题不工作我已经看到了这个How do I change the background color of the ActionBar of an ActionBarActivity using X
您好,我正在尝试将 Intent 传递给 FragmentActivity,但它不起作用。 Activity 在 FragmentActivity 的初始化中关闭。这是 Activity : publ
在我的应用程序中,我有选项卡,但现在我需要添加 Sherlock Actionbar 我知道我需要使用 extends SherlockActivity 但早期我有 FragmentActivity
我正在尝试将 ActionBar 按钮添加到 FragmentActivity,但我无法弄清楚我做错了什么。运行应用程序时,我看到的只是 ActionBar 上的默认菜单按钮,而不是我的按钮。 fra
我正在扩展类中的 FragmentActivity,该类用作我的其他 Activity 的基础 Activity 。我的问题是当我从我的基本 Activity 扩展我的其他 Activity 时,我失
我正在使用 android 示例,FragmentTabs . 比如说,有 4 个选项卡(A、B、C、D)。我使用此代码将选项卡 fragment (A) 替换为另一个 (E) FragmentTra
我是一名优秀的程序员,十分优秀!