English 中文(简体)
参考文献
原标题:LIst view in Android
  • 时间:2012-04-24 06:50:38
  •  标签:
  • android

In my sample program in 1stscreen i have one input field,based on this input i have to show a list view(which is another activity)how can i implement that.I am new to android.Here is my code.

这是在点击后:

if(text1.getText().toString().equals("subbu"))
            { 
                startActivity(new Intent(Listview));
//              Toast.makeText(Sampleprojectsubbu1Activity.this,"Name:"+text1.getText().toString(), Toast.LENGTH_LONG).show();              
            }

清单如下: 就抽样而言,我提供了一些不想要的阵列。

public class Listview extends ListActivity 
{
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, COUNTRIES));

    }
    static final String[] COUNTRIES = new String[] 
            {
                   "XXXXX","YYYYYY"

            };

}
最佳回答

Wrong:

 startActivity(new Intent(Listview));

正确开端方式 活动:

startActivity(new Intent(CurrentClassName.this, DestinationClassName.class));

Update:

了解更多关于意向、检查和读到以下条款:

  1. Android Intents
  2. Intents and Intent Filters
问题回答

主要活动:

Intent myIntent = new Intent(this, ListView.class);
myIntent.putExtra("variableName", variableValue);
this.startActivity(myIntent);

Bundle extras = getIntent().getExtras();
if (extras != null) {
String varName = extras.getString("variableName");//Datatype can be any
}

你们必须这样做,代之以代号。

1. 启动(新加入(Listview);

启动(MainActivty.this,ListView.class);

此外,必须明确增加这一新活动。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签