我有3个标签.第一个标签包含第一个活动 第二个标签包含第二个活动
第1个活动包含项目列表.
当我点击列表中的项目时,我通过意图将其信息传递给第二个标签中的第二个活动.
现在我想启动第二个选项卡,显示包含第一个活动信息的第二个活动.
怎么实现这个?
我有一个TabActivity.每个选项卡都指向子活动.这非常有效.
是否有任何聪明的方法来刷新其中一个活动标签?我只想"重新启动"标签#3中的活动.除了构建对活动本身的刷新支持,或者清除所有选项卡并重新创建所有选项卡之外,还不确定这样做的好方法.
谢谢,
我创建了可滚动的标签栏,使用tabhost,tabwidget和horizontalscrollbar,它是layout_gravity的底部.现在,我想为它创建自定义API,所以任何人都可以使用api根据他们的reqiurment改变文本大小,高度,宽度等.
Tabbar.java
package com.tabbar.project;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.TabHost;
public class Tabbar extends TabActivity {  
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);   
        Resources res = getResources();
        // TabHost will have Tabs
        TabHost tabHost = getTabHost();
        /* TabSpec used to create a new tab. 
         * By using TabSpec only we can able to setContent to the tab.
         * By using TabSpec setIndicator() …android custom-application android-tabhost android-tabactivity
我知道这里有一百万人,已经有一百万人报道过这里的灾难性事件.我有开发人员参考,并且已经阅读了我可以在SO上找到的所有主题.我的问题是,片段真的很复杂吗?从我可以收集到的,似乎是,而TabActivty非常容易.见下面的例子:
四个选项卡所需的当前代码如下所示:
Resources res = getResources(); // Resource object to get Drawables
        TabHost tabHost = getTabHost(); // The activity TabHost
        TabHost.TabSpec spec; // Resusable TabSpec for each tab
        Intent intent; // Reusable Intent for each tab
        // Create an Intent to launch an Activity for the tab (to be reused)
        intent = new Intent().setClass(this, ServerActivity.class);
        // Initialize a TabSpec for each tab and add it to the TabHost
        spec = tabHost
                .newTabSpec("server")
                .setIndicator("Server",
                        res.getDrawable(R.drawable.ic_tab_server))
                .setContent(intent);
        tabHost.addTab(spec);
        // Do the same …android android-fragments android-tabactivity android-activity
我已经阅读了很多示例,问题和教程,但我从未见过具有特定选项卡的活动启动(启动新意图).我知道可以使用.setCurrentTab切换到选项卡,但这只能从父活动选项卡内部完成.如何从不同的活动中启动一个活动中包含的特定选项卡?可能吗?如果是这样,那怎么样?
在我的代码中,在标准活动启动用户显示第一个选项卡,但我希望他转到第四个选项卡,以防他从另一个活动重定向.我的TabHost代码(MyTabActivity):
int tabIndex = 0;
          mTabHost.addTab(mTabHost.newTabSpec("top10").setIndicator("Top 10").setContent(R.id.Top_10));
          mTabHost.addTab(mTabHost.newTabSpec("billable").setIndicator("Billable").setContent(R.id.Billable));
          mTabHost.addTab(mTabHost.newTabSpec("product").setIndicator("Product").setContent(R.id.Product));
          mTabHost.addTab(mTabHost.newTabSpec("regular").setIndicator("Regular").setContent(R.id.General));
          mTabHost.setCurrentTab(tabIndex);
现在进行另一项活动:
public void gotoTab() {
//This will take me to the first tab
Intent i = new Intent(this, MyTabActivity.class);
startActivity(i);
finish();
//How to I make it take me to the fourth tab?
}
我用谷歌搜索了,但找不到任何解决方案请帮助.我创建了一个tabbar视图,其中有3个Tabhost选项卡,并使用TabSpec设置其标题,如下所示:
TabSpec tbhome = tabHost.newTabSpec("Home");
tbhome.setIndicator("Selected Topic");
我的另一个标签中有2个按钮,位于上方标签旁边.现在我想要的是,如果我单击此选项卡中的按钮,则必须将此按钮的标题设置为我的主页选项卡的标题.在上面的代码中,"Selected Topic"必须设置为我的按钮的标题.
谢谢.
好吧,我现在才开始进入Android编程,我正在关注android"TabActivity"教程:http://developer.android.com/reference/android/app/TabActivity.html.Everythings工作,但它似乎无法找到一些支持类,请参阅下面的代码生成错误.
    mTabManager.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"),
            FragmentStackSupport.CountingFragment.class, null);
    mTabManager.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"),
            LoaderCursorSupport.CursorLoaderListFragment.class, null);
    mTabManager.addTab(mTabHost.newTabSpec("custom").setIndicator("Custom"), 
            LoaderCustomSupport.AppListFragment.class, null);
    mTabManager.addTab(mTabHost.newTabSpec("throttle").setIndicator("Throttle"),
            LoaderThrottleSupport.ThrottledLoaderListFragment.class,null);
对于FragmentStackSupport/LoaderCursorSupport/LoaderCustomSupport/LoaderThrottleSupport,它表示所有这些都无法解析为某种类型.我已将最新的支持库添加到名为"libs"的根目录中的文件夹中,并将其更新为"C:/ Eclipse/v4 /"目录.我的导入文件是:
    import java.util.HashMap;
    import android.R;
    import android.content.Context;
    import android.os.Bundle;
    import android.support.v4.app.Fragment;
    import android.support.v4.app.FragmentActivity;
    import android.support.v4.app.FragmentTransaction;
    import android.support.v4.app.FragmentPagerAdapter;
    import android.view.View;
    import android.widget.TabHost;
    import cowdawg.hello_tab.namespace.R.layout;
    import cowdawg.hello_tab.namespace.R.id;
有人可以请给我一些关于如何解决这个问题的建议,谢谢:).
我正在尝试在Android中编写代码,以在向下滚动事件期间隐藏Actionbar.我有一个10x50的网格.因此,当我向下滚动时,操作栏应该隐藏.我正确地在Log Cat中获得滚动状态结果,所以每当我申请getActionBar()时,我都会收到NullPointerException错误.
我的代码:
package com.example.complexdatepicker;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
public class MainActivity extends TabActivity 
{
@Override
protected void onCreate(Bundle savedInstanceState) 
{
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TabHost tabHost = getTabHost();
        TabSpec tab1 = tabHost.newTabSpec("Home");
        tab1.setIndicator("Home");
        Intent photosIntent = new Intent(this, Home.class);
        tab1.setContent(photosIntent);
        tabHost.addTab(tab1);
}
 }
Home.java
package com.example.complexdatepicker;
import java.util.ArrayList;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.widget.GridView;
public class Home extends ActionBarActivity 
{
ArrayList<String> abc;
TestGrid tg;
GridView gv;
int mLastFirstVisibleItem;
int mLastVisibleItemCount;
@Override
protected void onCreate(Bundle savedInstanceState) …android nullpointerexception android-tabactivity android-actionbar
我已经单独完成了两项工作,我希望将这两项活动结合在一起.我不知道该怎么办.请帮帮我.
MainActivity.java
Public class MainActivity extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener {
private DrawerLayout mDrawerLayout;
private ListView mDrawerList;
private ActionBarDrawerToggle mDrawerToggle;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
   /* FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });*/
    Toast.makeText(getApplicationContext(),"WelCome to KulDiet",Toast.LENGTH_LONG).show();
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView …android android-tabactivity android-studio navigation-drawer
我有两个活动。第一个是包含列表视图的普通活动,第二个是带有两个选项卡的选项卡式布局。一个是“描述”选项卡,另一个是“样本代码”选项卡。
我为每个创建了两个单独的片段,即“ OneFragment”和“ TwoFragment”。我需要的是,当用户单击我正常活动中的某个项目时,该项目将存储在字符串中,并且该字符串应传递到选项卡式布局中,并应显示在OneFragment中,即“说明”选项卡
(例)。我的列表包含{“ Android”,“ Studio”},如果用户单击Android,则此文本应传递到说明标签,并使用TextView显示该文本。请帮我。在这里,我包括我各自的代码。
NormalActivity-> ListActi.java
   @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list);
        lv = (ListView) findViewById(R.id.listView);
        final List<String> ListElementsArrayList = new ArrayList<String>(Arrays.asList(listElements));
        final ArrayAdapter<String> adapter = new ArrayAdapter<String>
                (getApplicationContext(), android.R.layout.simple_list_item_1, ListElementsArrayList);
        lv.setAdapter(adapter);
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                //Toast.makeText(getApplicationContext(), listElements[position],Toast.LENGTH_LONG).show();
                s = listElements[position];
                if(position == 1){
                    s = listElements[position];
                    Bundle bundle = new Bundle();
                    bundle.putString("ClickedItem", listElements[position]);
                    OneFragment fragobj = new OneFragment();
                    TwoFragment fag = new TwoFragment(); …java android android-intent android-fragments android-tabactivity
单击我的Tab活动后,我需要刷新我的Activity.目前它只显示以前的内容.我需要刷新我的活动,因此可以在后面加载新内容.这是我添加TabActivity的代码.请帮忙.感谢您的所有反馈.
    private void setTabs()
{
    addTab("Home", R.drawable.tab_home, OptionsActivity.class);
    addTab("News", R.drawable.tab_search, JsonActivity.class);
    addTab("Scores", R.drawable.tab_home, scores.class);
    addTab("Video", R.drawable.tab_search, JsonActivity2.class);
    addTab("Follow Us", R.drawable.tab_home, SAXParserActivity.class);
    addTab("Socket", R.drawable.tab_search, socketAndroid.class);
}
private void addTab(String labelId, int drawableId, Class<?> c)
{
    TabHost tabHost = getTabHost();
    Intent intent = new Intent(this, c);
    TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId); 
    View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false);
    TextView title = (TextView) tabIndicator.findViewById(R.id.title);
    title.setText(labelId);
    ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
    icon.setImageResource(drawableId);
    spec.setIndicator(tabIndicator);
    spec.setContent(intent);
    tabHost.addTab(spec);
}
android refresh android-intent tabactivity android-tabactivity
我的应用程序中有一个标签激活,
这是一些简化的代码:
@SuppressLint("NewApi")
public class Rhino68PanelActivity extends FragmentActivity implements ActionBar.TabListener {
static String TAG = "Rhino68PanelActivty";
/**
 * The {@link android.support.v4.view.PagerAdapter} that will provide
 * fragments for each of the sections. We use a
 * {@link android.support.v4.app.FragmentPagerAdapter} derivative, which
 * will keep every loaded fragment in memory. If this becomes too memory
 * intensive, it may be best to switch to a
 * {@link android.support.v4.app.FragmentStatePagerAdapter}.
 */
SectionsPagerAdapter mSectionsPagerAdapter;
/**
 * The {@link ViewPager} that will host the section contents.
 */ …我想在我的Android应用程序上导入谷歌分析,我的代码是
private GoogleAnalyticsTracker tracker;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.demo);
    tracker = GoogleAnalyticsTracker.getInstance();
    tracker.startNewSession(getString(R.string.analytics_id), this);
    tracker.trackPageView("/demo");
}
@Override
protected void onDestroy() {
    super.onDestroy();
    tracker.stopSession();
}
但它不起作用......我在哪里做错了?谢谢......注意:我使用了tabactivity和每个标签代码......