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

  • Home
  • SEARCH
  • 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 9228011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:13:22+00:00 2026-06-18T05:13:22+00:00

I have two activities. One displays all the notices in a listview and it

  • 0

I have two activities.
One displays all the notices in a listview and it displays links to pdf files.
Second activity runs when an item is selected. Basically second activity should fire up on item click and it should open the pdf file.

Well the thing is that it does not fire up 2nd activity on item select. Posting the code for your reference.

CODE:

AllEventsActivity.java

     public class AllEventsActivity extends ListActivity {


private ProgressDialog pDialog;

// Creating JSON Parser object
JSONParser jParser = new JSONParser();

ArrayList<HashMap<String, String>> productsList;


private static String url_all_products = "http://myurl/fetchnotice.php";

// JSON Node names
private static final String TAG_SUCCESS = "success";
private static final String TAG_PRODUCTS = "notices";
private static final String TAG_PID = "nid";
private static final String TAG_NAME = "notice";
private static final String TAG_INFO = "noticeinfo";
private static final String TAG_DATE = "date";

// products JSONArray
JSONArray products = null;

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

    // Hashmap for ListView
    productsList = new ArrayList<HashMap<String, String>>();
    Button go_btn = (Button) findViewById(R.id.go_btn);
    // Loading products in Background Thread
    new LoadAllProducts().execute();

    // Get listview
    ListView lv = getListView();


    // on seleting single product
    // launching pdfviewer activity
    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
            // getting values from selected ListItem
            String pid = ((TextView) view.findViewById(R.id.einfo)).getText()
                    .toString();

            // Starting new intent
            Intent in = new Intent(getApplicationContext(),
                    PdfViewActivity.class);
            // sending pid to next activity
            in.putExtra("pathid", pid);

            // starting new activity and expecting some response back
            startActivityForResult(in, 100);
        }
    });

}

// Response from Edit Product Activity
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // if result code 100
    if (resultCode == 100) {
        // if result code 100 is received
        // means user edited/deleted product
        // reload this screen again
        Intent intent = getIntent();
        finish();
        startActivity(intent);
    }

}

class LoadAllProducts extends AsyncTask<String, String, String> {

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(AllEventsActivity.this);
        pDialog.setMessage("Loading results. Please wait...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(false);
        pDialog.show();
    }

    protected String doInBackground(String... args) {
        // Building Parameters
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        // getting JSON string from URL
        JSONObject json = jParser.makeHttpRequest(url_all_products, "GET", params);

        // Check your log cat for JSON reponse
        Log.d("All Products: ", json.toString());

        try {
            // Checking for SUCCESS TAG
            int success = json.getInt(TAG_SUCCESS);

            if (success == 1) {
                // products found
                // Getting Array of Products
                products = json.getJSONArray(TAG_PRODUCTS);

                // looping through All Products
                for (int i = 0; i < products.length(); i++) {
                    JSONObject c = products.getJSONObject(i);

                    // Storing each json item in variable
                    String id = c.getString(TAG_PID);
                    String name = c.getString(TAG_NAME);
                    String info = c.getString(TAG_INFO);
                    String date = c.getString(TAG_DATE);
                    // creating new HashMap
                    HashMap<String, String> map = new HashMap<String, String>();

                    // adding each child node to HashMap key => value
                    map.put(TAG_PID, id);
                    map.put(TAG_NAME, name);
                    map.put(TAG_INFO, info);
                    map.put(TAG_DATE, date);
                    // adding HashList to ArrayList
                    productsList.add(map);
                }
            } else {
                // nothing found
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    protected void onPostExecute(String file_url) {
        // dismiss the dialog after getting all products
        pDialog.dismiss();
        // updating UI from Background Thread
        runOnUiThread(new Runnable() {
            public void run() {
                /**
                 * Updating parsed JSON data into ListView
                 * */
                ListAdapter adapter = new SimpleAdapter(
                        AllEventsActivity.this, productsList,
                        R.layout.list_item_eve, new String[] { TAG_PID,
                                TAG_NAME, TAG_INFO, TAG_DATE },
                        new int[] { R.id.eid, R.id.ename, R.id.einfo, R.id.date});
                // updating listview
                setListAdapter(adapter);
            }
        });

    }
}
}

2nd Activity:

       public class PdfViewActivity extends Activity { 


   private WebView webview;

    //private ProgressDialog progressDialog;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.photoview);

        webview = (WebView) findViewById(R.id.my_img);
        webview.getSettings().setBuiltInZoomControls(true);
        webview.getSettings().setUseWideViewPort(true);
        webview.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);

        String id = getIntent().getExtras().getString("pathid");
        webview.loadUrl("http://docs.google.com/viewer?url="+id);
    }
  }

XML code: list_item_eve.xml

   <?xml version="1.0" encoding="utf-8"?>

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" 
android:background="@color/itm_bg"
android:textColor="@drawable/text_color">

<TextView
    android:id="@+id/eid"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:visibility="gone" 
    android:textColor="@drawable/text_color"/>

<!-- Name Label -->
<TextView
    android:id="@+id/ename"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingTop="6dip"
    android:paddingLeft="6dip"
    android:textSize="12dip"
    android:textStyle="italic" 
    android:textColor="@drawable/text_color"/>


<TextView
    android:id="@+id/einfo"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="12dip"
    android:autoLink="web"
    android:textColorLink="@color/link"
    android:paddingTop="6dip"
    android:textSize="14dip"
    android:textStyle="bold" 
    android:textColor="@drawable/text_color"/>

<TextView
    android:id="@+id/date"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:autoLink="web"
    android:textColorLink="@color/link"
    android:paddingLeft="15dip"
    android:paddingTop="6dip"
    android:textColor="#ffffff"
    android:textSize="9dip"
    android:textStyle="italic" />

<View android:id="@+id/sepbottom" 
      android:background="#000000" 
      android:layout_width = "fill_parent"
      android:layout_height="2dip"
      android:layout_marginTop="10dip"
      />

</LinearLayout>

all_events.xml

       <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@color/itm_bg"
android:textColor="@drawable/text_color">

<ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"/>

</LinearLayout>
  • 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-18T05:13:23+00:00Added an answer on June 18, 2026 at 5:13 am

    The easiest and most appropriate approach would be to set all child views inside ListView item to not focusable/not clickable, like this:

      <?xml version="1.0" encoding="utf-8"?>
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:orientation="vertical" 
       android:background="@color/itm_bg"
       android:textColor="@drawable/text_color">
    
    <TextView
    android:id="@+id/eid"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:visibility="gone" 
    android:focusable="false"
    android:clickable="false"
     android:textColor="@drawable/text_color"/>
    
       <!-- Name Label -->
      <TextView
    android:id="@+id/ename"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingTop="6dip"
    android:paddingLeft="6dip"
    android:textSize="12dip"
    android:textStyle="italic" 
    android:focusable="false"
    android:clickable="false"
    android:textColor="@drawable/text_color"/>
    
    
    <TextView
    android:id="@+id/einfo"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="12dip"
    android:autoLink="web"
    android:textColorLink="@color/link"
    android:paddingTop="6dip"
    android:textSize="14dip"
    android:textStyle="bold" 
    android:focusable="false"
    android:clickable="false"
    android:textColor="@drawable/text_color"/>
    
    <TextView
    android:id="@+id/date"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:autoLink="web"
    android:textColorLink="@color/link"
    android:paddingLeft="15dip"
    android:paddingTop="6dip"
    android:textColor="#ffffff"
     android:textSize="9dip"
    android:focusable="false"
     android:clickable="false"
     android:textStyle="italic" />
    
    <View android:id="@+id/sepbottom" 
      android:background="#000000" 
      android:layout_width = "fill_parent"
      android:layout_height="2dip"
      android:focusable="false"
      android:clickable="false"
      android:layout_marginTop="10dip"
      />
    
       </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two Activities in my App, one is a ListView which displays a
This is my situation. I have two activities: ONE and TWO. In TWO activity
If I have two activities in my app, one with listview and the other
I have one class called Global and two other activities. In each activity I
I have two activities. In first I come to the second activity from first
I have two Activities: one with VideoView attached to MediaPlayer and the second one.
I have two activities, one is main and I have another activity called Test
I have two activities - one displays data from SQLite , and the other
I have two activities one displaying map view and another listview, the main objective
I have two different activities. The first launches the second one. In the second

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.