I have to display category name on android textview with array items.here the total category size is 5.
I have wrote the below code:
for (int i = 0; i < sitesList.getName().size(); i++) {
name[] = (TextView) findViewById(R.id.title);
name[].setText(sitesList.getCategory().get(i).toUpperCase());
now i have to run the app which means am getting the last (5th) category name alone.But i wish to display the all(total=5) categories.
for (int i = 0; i < sitesList.getName().size(); i++) {
name[i] = (TextView) findViewById(R.id.title);
name[i].setText(sitesList.getCategory().get(i).toUpperCase());
Now i have to run the app means my app is force closed.How can i resolve these error ??? please give me solution for these ???
My console window shows:
03-12 06:36:08.789: E/AndroidRuntime(886): Caused by: java.lang.NullPointerException
03-12 06:36:08.789: E/AndroidRuntime(886): at com.xmlparsing.MainActivity.onCreate(MainActivity.java:72)
03-12 06:36:08.789: E/AndroidRuntime(886): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
In my code 72th line is :
name[i] = (TextView) findViewById(R.id.title);
But i have to create the textview programmatically which means its worked well and displayed all(total=5) categories well.