-1

这是代码,这将打开一个带有名称的列表,但它在一个新窗口中。我想要做的是把这个列表放在主窗口上。我能做些什么?

在此处输入图像描述

 public class MainActivity extends ListActivity {

            String []name={"bill","gorg"};

            @Override
            public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);

                //setContentView(R.layout.activity_main);

                setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,name));
            }

            @Override
            protected void onListItemClick(ListView l, View v, int position, long id) {
                // TODO Auto-generated method stub
                super.onListItemClick(l, v, position, id);
                Object o=this.getListAdapter().getItem(position);
                String keybord= o.toString();
                Toast.makeText(this, "you are select "+keybord, Toast.LENGTH_LONG).show();
            }

            @Override
            public boolean onCreateOptionsMenu(Menu menu) {
                getMenuInflater().inflate(R.menu.activity_main, menu);
                return true;
            }
        }
4

1 回答 1

0

When you say "main window" do you mean the home screen of an Android device? If that's what you are referring to, it's not exactly possible. The home screen is an application itself, that can link to other applications which you can see on your "desktop". If you want to be able to display a list of something, then you could create a widget along with your app and the widget could be displayed on one of the panels of a device's home screen.

If you want to create a widget that can be added to the home screen, check the widget developer docs

于 2012-11-01T23:51:08.393 回答