Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9145571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:32:51+00:00 2026-06-17T10:32:51+00:00

I have a ListView with one TextView. List view is populated from a string

  • 0

I have a ListView with one TextView. List view is populated from a string array and array adapter(in the List class extending ListActivity & list_item layout). Now a click listener is set and using switch position statement and local html files from assets folder are linked to the list rows by uri parsing method. When the list row is clicked the html page is set to be displayed in a Webview set up with (TopicDisplay class & display_item layout). Below is my

PROBLEM: When the user clicks a row on the list view – html documents from that row to the last row are displayed with Last document first. I can use the android device back button to navigate through each html document loaded until the clicked row. HOW TO DISPLAY ONLY THE CLICKED ROW HTML DOCUMENT?

Code in List Class

package com.abcdef.list;



//import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
//import android.widget.AdapterView;
//import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
//import android.widget.TextView;

public class List extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // storing string resources into Array
    String[] adobe_products = getResources().getStringArray(R.array.adobe_products);

    // Binding resources Array to ListAdapter
    this.setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, R.id.label, adobe_products));
}   
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    change(position);
}
void change(int position){
 //   Uri uri = null;
    switch(position){   

case 0 :{
    Intent i0 = new Intent(getApplicationContext(), TopicDisplay.class);
  Uri  uri0=Uri.parse("file:///android_asset/File0.html");
    i0.setData(uri0);
    startActivity(i0);}
case 1 :{
    Intent i1 = new Intent(getApplicationContext(), TopicDisplay.class);
  Uri  uri1=Uri.parse("file:///android_asset/Topic1.html");
    i1.setData(uri1);
    startActivity(i1);}
case 2 :{
    Intent i2 = new Intent(getApplicationContext(), TopicDisplay.class);
    Uri   uri2=Uri.parse("file:///android_asset/Topic2.html");
    i2.setData(uri2);
    startActivity(i2);}

case 3:{
    Intent i3 = new Intent(getApplicationContext(), TopicDisplay.class);
    Uri  uri3=Uri.parse("file:///android_asset/Topic3.html");
    i3.setData(uri3);
    startActivity(i3);}
  case 4:{
      Intent i4 = new Intent(getApplicationContext(), TopicDisplay.class);
      Uri    uri4=Uri.parse("file:///android_asset/Topic4.html");
    i4.setData(uri4);
    startActivity(i4);}
 case 5:{
     Intent i5 = new Intent(getApplicationContext(), TopicDisplay.class);
     Uri  uri5=Uri.parse("file:///android_asset/Topic5.html");
    i5.setData(uri5);
    startActivity(i5);}
 case 6:{
     Intent i6 = new Intent(getApplicationContext(), TopicDisplay.class);
     Uri  uri6=Uri.parse("file:///android_asset/Topic6.html");
     i6.setData(uri6);
     startActivity(i6);}
  case 7:{
      Intent i7 = new Intent(getApplicationContext(), TopicDisplay.class);
      Uri  uri7=Uri.parse("file:///android_asset/Topic7.html");
     i7.setData(uri7);
     startActivity(i7);}
  case 8:{
      Intent i8 = new Intent(getApplicationContext(), TopicDisplay.class);
      Uri  uri8=Uri.parse("file:///android_asset/Topic8.html");
     i8.setData(uri8);
     startActivity(i8);}  
   } } }

Here is my TopicDisplay class code

package com.abcdef.list;

import android.app.Activity;
//import android.app.Application;
//import android.content.Intent;
import android.os.Bundle;
import android.webkit.*;

public class TopicDisplay extends Activity{



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


    WebView tabViewing = (WebView) findViewById(R.id.webView1);
    tabViewing.loadUrl(getIntent().getDataString());

}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:32:53+00:00Added an answer on June 17, 2026 at 10:32 am

    When the user clicks a row on the list view – html documents from that row to the last row are displayed with Last document first.

    You simply forgot to add break; to each case in your switch statement.

    You should also remove the common code from each case statement, try:

    Intent intent = new Intent(getApplicationContext(), TopicDisplay.class);
    switch(position){   
    case 0 :
        intent.setData(Uri.parse("file:///android_asset/File0.html"));
        break;
    case 1 :
        intent.setData(Uri.parse("file:///android_asset/Topic1.html"));
        break;
    case 2 :
        intent.setData(Uri.parse("file:///android_asset/Topic2.html"));
        break;
    // etc
    }
    startActivity(intent);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this View Adapter method for a ListView which is populated from a
I have created a custom listview using adapter. Each row of the list view
I have listview having customized some textview and one imageview. When I long click
I have a ListView with multiple checkboxes (one for each list item). What would
I have a tab view which has a listview in one of these tabs.
I have a ArrayAdapter which is populated using a POJO class. The listview comprises
I have a listView, one component of the row is a TextView. By default,
Hi I have a Custom ListView with one ImageView and TextView . Here is
I have a ListView with a custom view rendered by an adapter. It contains
I created a custom ListView. Each item in the list have one imageView and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.