实施"追溯"导航Android应用程序的用户界面用户界面、应用程序、QUOT、Android

2023-09-05 05:52:25 作者:行尸走肉

我想学习如何做的东西在Android中,我不知道,以建立界面的最佳方式。

I am trying to learn how to do stuff in Android, and I'm not sure of the best way to build the interface.

我一直对移植的iPhone应用程序,它使用导航控制器和表视图查看不同的部分:基本上,人触摸的表,它向下钻取到另一个表的单元格。当他们接触的细胞在该表它能够深入到显示信息的web视图。

I've been working on porting an iPhone app, which uses navigation controllers and table views for looking at the different sections: basically, someone touches a cell in the table, which drills down to another table. when they touch a cell on that table it drills down to a webview that displays the information.

我想要做类似的Andr​​oid应用程序的东西,但我不知道怎么回事,或者是否有更好的方式,原产于Android系统。我已经想通了如何使用web视图我的目的,但前进和后退表中的树目前尚不清楚。

I want to do something similar for the android app, but I don't know how, or if there is a better way native to Android. I've figured out how to use the webview to my purposes, but moving forward and backward in the table tree is unclear.

推荐答案

于是就当你说钻到我想,当用户触摸式上的列表行,它滑动从右边一个新的观点,你的意思是一个iphone ,大部分时间它在顶部导航栏,给用户的选择回去吗?

So on an iphone when you say drill down I guess you mean when a user touches-up on a list row and it slides a new view on from the right, most of the time it has a nav bar at the top to give the user the option to go back?

在Android的方式处理这简直是通过启动一个新的活动。所以,你将有你的图书ListActivity时的listItem点击你需要定义一个新的intent启动你的'章'ListActivity等。在一个iPhone顶部的导航栏是不是在Android的标准UI,因为大多数人看到专用的返回键再回到previews屏幕的方式。

The way android handles this is simply by starting a new activity. So you would have your 'Books' ListActivity when a listItem is clicked you would define a new intent that starts your 'Chapters' ListActivity and so on. The nav bar at the top of an iphone is not standard UI in android as most people see the dedicated 'back' key as a way of getting back to the previews screen.

这是如何在你以前没见过的情况下启动一个意图:

This is how you start an intent in case you haven't seen it before:

Intent chaptersIntent = new Intent(this, Chapters.class);
this.startActivity(chaptersIntent);

这篇文章值得一读快速通过,因为它解释活动完美

This article is worth a quick read through as it explains Activities perfectly

http://d.android.com/guide/topics/fundamentals.html

另外看看Android版的TableView的 - ListView的:

Also have a look at the android version of TableView - ListView:

http://d.android.com/reference/android/widget/ListView.html

和ListActivity:

and ListActivity:

http://d.android.com/reference/android/app/ListActivity.html

:样品code 我会做这样的事情

: Sample Code I would do it something like this

public class Books extends ListActivity {

private String[] mBooks = new String[]{ "Book1", "Book2", "Book3", "Book4" };

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

    ArrayAdapter<String> booksAdapter = new ArrayAdapter<String>(this, 
            android.R.layout.simple_list_item_1, 
            android.R.id.text1, 
            mBooks);

    this.setListAdapter(booksAdapter);

}

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    Intent mViewChaptersIntent = new Intent(this, Chapters.class);
    mViewChaptersIntent.putExtra("BookName", mBooks[position]);
    startActivity(mViewChaptersIntent);
}

}

所以,你通过这本书的ID传递作为额外的意图,然后在你的章节的活动,你获得额外的onCreate方法:

So you pass through the id of the book as an extra to the Intent then in your Chapters Activity you get that extra in the onCreate method:

    @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Bundle extras = getIntent().getExtras();
    if(extras != null) {
        String bookId = extras.getString("BookName");
    }
}

最后,确保所有新活动添加到您的Andr​​oidManifest.xml文件:

Finally make sure all new activities are added to your AndroidManifest.xml file:

<activity android:name=".YourClassName"
  android:label="@string/activity_name"
  >
</activity>

希望帮助