标签: android-tabhost

Tabhost底部边界线android

截图

请注意,在选项卡下方运行的小灰线(选定选项卡除外)?我该如何更改/更改?

那会是FrameLayout,tabHost还是TabWidget的一部分?我只是找不到改变或删除这条小灰线的方法.

谢谢

android android-tabhost

4
推荐指数
2
解决办法
8634
查看次数

有没有办法在TabHost中显示片段?

我想在TabHost中为每个标签显示一个不同的片段.但似乎没有简单的方法可以做到这一点.TabHost只能接受A. Views或B.当用户选择选项卡时启动活动的意图.

使用A意味着我必须初始化每个片段并将它们加载到提供给TabHost的容器视图中.但是我希望这些片段只在需要时加载 - 当用户选择它们的标签时.

使用B表示我将片段加载到每个选项卡的单独活动中.但是我希望片段能够到达"原始"父级Activity,而不仅仅是一些在Tab选项中托管它们的shell Activity.

我错过了什么吗?有没有办法正确管理TabHost片段?

android android-tabhost android-fragments android-3.0-honeycomb

4
推荐指数
1
解决办法
1万
查看次数

从另一个Activity访问TabHost

我需要从所有活动中更改TabHost.我做了一些研究,但我没有发现任何与TabHost兼容的东西.

我希望能够从另一个Activity中隐藏TabHost.(如果我设法访问它,隐藏它对我来说不是问题)

我之前曾使用过一些公共静态函数,但却无法使用TabHost.我需要它可以从所有活动中更改的原因是TabHost应该只消除特定活动的结果.

TabHost是股票.

android android-tabhost android-activity

4
推荐指数
1
解决办法
1513
查看次数

Android,意图不起作用?

这是我的代码.它很简单但是当我点击按钮"button1"时,没有任何反应.我做错了什么?

public class TestTab extends Activity {

    Button button1;
        Intent i;


    @Override

    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        button1 = (Button) findViewById(R.id.btnScore);
        button1.setOnClickListener(new View.OnClickListener() {


            @Override
            public void onClick(View v) {

                Toast.makeText(getApplicationContext(), "On Click Event", 5000).show();

                //i = new Intent(TestTab.this, AndroidTab.class);
                //startActivity(i);

            }

        });
   }}
Run Code Online (Sandbox Code Playgroud)

第二 -

package com.example.picturegame2;

import android.app.TabActivity;


public class AndroidTab extends TabActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tabzz);

        TabHost tabHost = getTabHost(); …
Run Code Online (Sandbox Code Playgroud)

tabs android button android-intent android-tabhost

4
推荐指数
1
解决办法
3343
查看次数

软键盘提升tabhost向上

当软键盘打开时,我的TabHost向上移动 EditText

截图

软键盘上方的标签

我做了什么

  • 对于我getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);用来隐藏软键盘的每个活动

我试过了什么

  • 包含android:windowSoftInputMode="adjustPan|adjustResize"在清单文件中的活动

我已经经历了许多被接受的问题但是android:windowSoftInputMode="adjustPan|adjustResize在我的案例中没有工作.请建议如何处理这种情况.

编辑

tabhost.xml

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

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1" />

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

layout.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white" >

<RelativeLayout
    android:id="@+id/registrationLayout"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:background="#333333" >

    <ImageView
        android:id="@+id/activity_logo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="10dp"
        android:contentDescription="@string/content_description"
        android:src="@drawable/logo" />


    <RelativeLayout
        android:id="@+id/rl2"
        android:layout_width="match_parent"
        android:layout_height="38dp"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@+id/activity_logo"
        android:gravity="center_vertical" >

        <EditText
            android:id="@+id/searchEditText"
            android:layout_width="match_parent"
            android:layout_height="23dp"
            android:layout_marginLeft="6dp"
            android:layout_marginRight="6dp"
            android:background="@drawable/search_background"
            android:gravity="left|center_vertical"
            android:hint="Search for name"
            android:paddingLeft="6dp"
            android:textColor="@color/white"
            android:textSize="15sp" /> …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-softkeyboard android-tabhost android-view

4
推荐指数
1
解决办法
1544
查看次数

在新Intent中显示TabHost布局的问题

我在TabActivity类型的新Intent中使用TabHost时遇到问题,我希望你能指出我正确的方向.当我尝试在原始Intent中查看它时,它可以正常工作:setContentView(R.layout.main)

我得到一个"强制关闭"并在logcat中,即使我的Tabhost id ="@ android:id/tabhost",我也会收到以下错误:

02-18 22:23:11.937:ERROR/AndroidRuntime(5944):引起:java.lang.RuntimeException:您的内容必须有一个TabHost,其id属性为'android.R.id.tabhost'

我在Manifest.xml文件中声明了第二个意图:XML:

<activity android:name=".NextActivity" android:label="@string/app_name" > 
Run Code Online (Sandbox Code Playgroud)

在第一个活动(MainActivity)中,我使用extras启动第二个intent(NextActivity),如下所示:

Intent nextActivity = new Intent(MainActivity.this,NextActivity.class); 
Bundle b_next=new Bundle(); 

b_next.putString("s_string", myString); 

nextActivity.putExtras(b_next); 
Run Code Online (Sandbox Code Playgroud)

在我的NextActivity.java文件中,我获取了额外内容并尝试显示TabHost视图:

public class NextActivity extends TabActivity { 
     @Override 
     public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 

        String myString; 
        Bundle b_initial; 

        b_initial = getIntent().getExtras(); 

        myString = b_initial.getString("s_string"); 

     setContentView(R.layout.main); 

        } 
}
Run Code Online (Sandbox Code Playgroud)

我在Android Developer网站(Hellow View)上使用TabHost示例时遇到同样的错误:

main.xml中:

<?xml version="1.0" encoding="utf-8"?> 
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout 
        android:orientation="vertical" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"> 
        <TabWidget 
            android:id="@android:id/tabs" 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" /> 
        <FrameLayout 
            android:id="@android:id/tabcontent" 
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent"> 
            <TextView 
                android:id="@+id/textview1" 
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent" …
Run Code Online (Sandbox Code Playgroud)

android android-widget android-intent android-tabhost

3
推荐指数
1
解决办法
2万
查看次数

为什么我的ServiceConnection方法从未执行过?

这是调用我的服务的类:

public class TicketList extends ListActivity
{
private ArrayList<Tickets> alTickets = new ArrayList<Tickets>();
private boolean listCreated = false;
private static Drawable background = null;
private Resources res;
private Tickets ticket = null;
private TicketConnector localService;

/** 
 * Called when the activity is first created. 
 * 
 */
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ticketlist);

    if(!listCreated)
    {
        connectService();
        //populateList();

        res = getResources();
        background = res.getDrawable(R.drawable.background);
        listCreated = true;
    }

    TicketAdapter StatisticsAdapter = new TicketAdapter(this, alTickets);
    setListAdapter(StatisticsAdapter);
}

/**
 * Populates the …
Run Code Online (Sandbox Code Playgroud)

android android-service android-listview android-tabhost

3
推荐指数
1
解决办法
3057
查看次数

Tabhost nullpointerexception当tabhost不是布局中唯一的东西时

我注意到使用tabhost存在很多问题,但它们都不适合我的问题.我试图在顶部创建一个带有操作栏的视图,然后在栏下面创建一行标签.这是我的活动布局.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    style="@style/Dashboard">

    <com.ftni.common.ui.ActionBar
        android:id="@+id/actionbar"
        style="@style/ActionBar"/>

    <TabHost android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp">
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />
            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="5dp" />
        </LinearLayout>
    </TabHost>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

接下来,我们将我的活动声明为此类

public class DashboardActivity extends TabActivity {
Run Code Online (Sandbox Code Playgroud)

我正在构建我的标签.

private void buildTabs()
{
    Resources res = getResources(); // Resource object to get Drawables
    TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);  // The activity TabHost
    TabHost.TabSpec spec;  // Resusable TabSpec for each tab
    Intent intent;  // Reusable Intent …
Run Code Online (Sandbox Code Playgroud)

android nullpointerexception android-tabhost

3
推荐指数
1
解决办法
7620
查看次数

为什么eclipse突出显示R.id.tabhost?

我正在尝试在我的应用程序中实现选项卡,但是id tabhost正在突出显示,为什么?

我看的每个教程都有TabHost tabs =(TabHost)findViewById(R.id.tabhost),每次我都包含这行id tabhost是hightlighted,错误:tabhost无法解析或不是字段.

recipe_list.java:

    TabHost tabs=(TabHost)findViewById(R.id.tabhost);

tabs.setup();

TabHost.TabSpec spec=tabs.newTabSpec("tag1");

spec.setContent(R.id.tab1);
spec.setIndicator("Clock");
tabs.addTab(spec);

spec=tabs.newTabSpec("tag2");
spec.setContent(R.id.tab2);
spec.setIndicator("Button");
tabs.addTab(spec);
Run Code Online (Sandbox Code Playgroud)

recipe_list.xml,我在每个标签中都有列表视图:

   <TabHost
    android:id="@android:id/tabhost"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

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

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
        </TabWidget>

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <LinearLayout
                android:id="@+id/tab1"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >

                <ListView
                    android:id="@+id/listView1"
                    android:layout_width="match_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="1" >
                </ListView>

            </LinearLayout>

            <LinearLayout
                android:id="@+id/tab2"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >

                <ListView
                    android:id="@+id/listView2"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1" >
                </ListView>

            </LinearLayout>

            <LinearLayout
                android:id="@+id/tab3"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >
            </LinearLayout>
        </FrameLayout>
    </LinearLayout> …
Run Code Online (Sandbox Code Playgroud)

tabs android android-tabhost

3
推荐指数
1
解决办法
2299
查看次数

Android - android.widget.TabHost无法强制转换为android.support.v4.app.FragmentTabHost

我是Android的新手.我正在尝试设置一个简单的TabHost视图.

这是我的xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

      <TabHost
            android:id="@+id/tabhost"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

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

                <TabWidget
                    android:id="@+id/tabs"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                     android:background="#160203" />

                <FrameLayout
                    android:id="@+id/tabcontent"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"/>

            </LinearLayout>

        </TabHost>

</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

这是我的java代码:

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTabHost;

public class Tabhost extends FragmentActivity {

    private FragmentTabHost tabHost;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tabhost);

        tabHost = (FragmentTabHost) findViewById(R.id.tabhost);
        tabHost.setup(this, getSupportFragmentManager(), R.id.tabcontent);

        tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("Articulos"),
                ArticulosFragment.class, null);
        tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("Tutoriales"),
                TutorialesFragment.class, null);
        tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator("Cursos"),
                CursosFragment.class, null);


    }
}
Run Code Online (Sandbox Code Playgroud)

但该应用程序崩溃与此错误消息(我真的不知道这意味着):

在此输入图像描述

你觉得怎么回事?

java android android-tabhost

3
推荐指数
1
解决办法
2544
查看次数