English 中文(简体)
创建一个像在“电视和电影”应用中的“老板”小组
原标题:Creating a Android left panel just like the one in "TV & Movies" application in google tv

我的情况是,我需要成立一个左派小组。 我的经理说,这应当像在TV & 电影上应用“谷歌电视”的节目一样,该节目最初只展示微调器,并在内容上扩展至在聚焦时显示icon文字的权利。

我想像以下形象中的表格一样(白色箱是我的链接,红衣是我的左板):

“Required

Enlarged image can be viewed here

我对左小组的要求是:

  1. 它应扩展至右侧部分,只要其任何联系都集中起来。 我不应难于悲伤。 但是,如何让人们知道控制是小组的焦点/重点。

  2. 如果在左小组点点点点点击任何环节,则会把一次缝ed活动装入右侧的碎裂。 我也以工作方式这样做。 但是,我更想知道一些体面的好办法。

  3. 左派小组应减少宽度,在用户通过催复通知D-PAD纽顿将装货活动集中时,应隐藏一行。

  4. 我必须能够自由使用<>KEYBOARD<>/strong>。 左板和儿童活动的控制,载于container。 FrameLayout。 这是因为我申请的是谷歌电视,用户会利用<>D-Pad对导航进行预选。 这是主要问题...... 不能将儿童从控制到父母邻里控制。

To have all the above mentioned points, i looked at the TabHost but could not find a way to make it look like the one i need.

我也看到了,但其垂直表格填充了所有纵向可用空间,对我来说,位置无法控制,即需要像一个单独的小组结构一样,在任何需要的地方建立联系。 因此,这也失败了。

Now i decided to create one myself. I am doing it the following way:

  1. main.xml contains a FrameLayout at root that holds
    • FrameLayout for holding activities -- i have set its margin from left so that the next left panel would fit in that space & when would cover the frame instean of going under it when i animate the panel s size
    • RelativeLayout for holding left panel items.

<>Main.xml>:

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

<!-- 
    THIS First TabHost IS NOT USED AT ALL.
    I JUST PUT IT HERE AS THE underlying TabActivity required it and was giving me error.
    You can see its visibility is set to GONE.
    
    You can just minimize it and forget it as its a silly Workaround.
    and help me if you know of some better way
 -->
<TabHost
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:visibility="gone" >

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

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="100dp"
            android:layout_height="fill_parent"
            android:layout_weight="0"
            android:orientation="vertical" />

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

<!-- 
    Activities are loaded here in this frame.
    Its margin from Left is set to 150dp to have space.
    Its placed on the first place as the second RelativeLayout would be used as Left Panel.
-->
<FrameLayout
    android:id="@+id/container"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginLeft="150dp"
    android:nextFocusLeft="@+id/leftpanel"
    android:background="#CCAAAA" >
</FrameLayout>
    
<!--
    Left Panel holding links/buttons etc to load a separate activity in above FrameLayout 
 -->
<RelativeLayout
    android:id="@+id/leftpanel"
    android:layout_width="200dp"        
    android:layout_height="fill_parent"
    android:background="#33FAFAFA"
    android:focusable="True"
    android:orientation="vertical" >

    <Button
        android:id="@+id/btnArtists"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Artists" >
    </Button>

    <Button
        android:id="@+id/btnAlbum"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/btnArtists"
        android:text="Album" >
    </Button>

    <Button
        android:id="@+id/btnLogin"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="True"
        android:text="Login" >
    </Button>
</RelativeLayout>

<>主要表格活动如下:

public class TestActivity extends TabActivity {
FrameLayout container;
Intent artistsIntent;
Intent albumsIntent;

/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    
    container = (FrameLayout)findViewById(R.id.container);
    artistsIntent = new Intent().setClass(this, ArtistsActivity.class);
    albumsIntent = new Intent().setClass(this, AlbumsActivity.class);
    
    Button btnArtist = (Button)findViewById(R.id.btnArtists);        
    btnArtist.setOnClickListener(new OnClickListener() {
        
        public void onClick(View v) {
            container.removeAllViews();
            View view = getLocalActivityManager().startActivity("ArtistsActivity",
                    new Intent(getApplicationContext(), ArtistsActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
            container.addView(view);                
        }
    });
    
    Button btnlbum = (Button)findViewById(R.id.btnAlbum);
    btnlbum.setOnClickListener(new OnClickListener() {
        
        public void onClick(View v) {
            container.removeAllViews();   
            View view = getLocalActivityManager().startActivity("AlbumsActivity",
                    new Intent(getApplicationContext(), AlbumsActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
            container.addView(view);
            
        }
    });
}    
}

你们可以看到,主要的测试活动是TabActative,为实施表格提供了功能。 我从TabActative上扩展了我的活动,因为据我所知,这是在儿童观点中增加一项活动的唯一途径。

这也迫使我有一个具体名字的<>TabHost。 因此,我添加了这一句,并将其引向gone,以使其不再提出申诉。 页: 1 THIS IS A SILLY WorkingAROUND. 如果我知道某种适当方式,BUT i就不在此帮助我,如果这样做有更好的办法。

我目前的测试项目的另一个问题是,当把一个子集中到一个装在的儿童活动中时。 FrameLayout利用右arrow钥匙。 我无法利用<>LEFT重新关注左边小组的县。 B. 关键事项

HOW to DO IT????

www.un.org/Depts/DGACM/index_spanish.htm 我已上载了小型样本项目here。 请下载并查阅。 还确定了甲型六氯环己烷和甲型六氯环己烷的实验主题:theme="@android:et/Theme.Holo”in Manifest.xml,以便按预期在完全屏幕上看到该仪器。

非常感谢你的帮助。

www.un.org/Depts/DGACM/index_spanish.htm NOTE:我正在为谷歌电视制作这一信号,其中导航主要取决于D-Pad...,因此,我必须确保我能够使用Kay板到达任何地方。

因此,我帮助我。

最佳回答

如果我没有错的话,请查阅http://code.google.com/p/googletv-android-samples/source/browse/#git/LeftNavBarLibrary” rel=“nofollow”Left Navigation Bar Library

还见

问题回答

Android碎块对你来说是完美的。 查看documentation,这确实是清楚的,并解释如何适当使用。





相关问题
In Eclipse, why doesn t "Show In" appear for non-Java files?

If I have a *java file open, I can right click on the source, scroll down to "Show In (Alt-Shift-W)", and select Navigator. If I have an *xml, *jsp, or pretty much anything besides a Java source ...

Eclipse: Hover broken in debug perspective

Since upgrading Eclipse (Galileo build 20090920-1017), hover in debug no longer displays a variable s value. Instead, hover behaves as if I were in normal Java perspective: alt text http://...

Eclipse smart quotes - like in Textmate

Happy Friday — Does anyone know if eclipse has the notion of smart quotes like Textmate. The way it works is to select some words and quote them by simply hitting the " key? I m a newbie here so be ...

Indentation guide for the eclipse editor

Is there a setting or plugin for eclipse that can show indentation guides in the editor? Something like the Codekana plugin for visual studio (not so fancy is also OK). Important that it works with ...

Adding jar from Eclipse plugin runtime tab

I want to add .jar files for plugin from the Runtime tab of manifest file. When I use the Add... button, I can see only sub-directories of the plugin project. So if I want to add same .jar file to ...

How to copy multiple projects into single folder in eclipse

I have two projects, Project1 and Project2. Now i want to copy this projects into eclipse workspace but i want these projects to be in a single folder like below. Eclipse Workspace -> Project -> ...

Java: Finding out what is using all the memory

I have a java application that runs out of memory, but I have no idea which code is allocating the memory. Is there an application with which I can check this? I use Eclipse.

热门标签