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 3870668
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T21:45:00+00:00 2026-05-19T21:45:00+00:00

How can i open new window (TextView) from ListView by setOnItemClickListener? I have tried

  • 0

How can i open new window (TextView) from ListView by setOnItemClickListener?
I have tried it but it’s failed.I have two Xml files (i don’t know if i can have 2) and in second Xml file is that TextView. I am trying if i click on any item in ListView it will open new window with TextView.

There is my attempt:

 list.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> arg0, View view, int position,
                    long id) {
                 TextView message = (TextView)findViewById(R.id.message);
                 Uri uriSMSURIs = Uri.parse("content://sms/inbox");
                 Cursor c = getContentResolver().query(uriSMSURIs, null, null, null, null);
                 String bodys = c.getString(c.getColumnIndexOrThrow("body"));        
                 setContentView(R.layout.text);  ----> this is name of second Xml file "Text.xml"
                 message.setText(bodys);

            }

        });
  • 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-05-19T21:45:00+00:00Added an answer on May 19, 2026 at 9:45 pm

    If you want a new window in terms of an AlertDialog, then you should create one by reading this example: creating AlertDialogs

    otherwise if you want to create a new Activity then i would do the following:

    list.setOnItemClickListener(new OnItemClickListener() {
    
            @Override
            public void onItemClick(AdapterView<?> arg0, View view, int position,
                    long id) {
    
                 Uri uriSMSURIs = Uri.parse("content://sms/inbox");
                 Cursor c = getContentResolver().query(uriSMSURIs, null, null, null, null);
                 String bodys = c.getString(c.getColumnIndexOrThrow("body"));        
    
    
                 Intent textIntent = new Intent(view.getContext(), TextMessage.class);
                 textIntent.putExtra(thisClass.class.getName(),bodys);
                 thisClass.this.stratActivity(textIntent); 
    
            }
    
        });
    

    With this now you can define a new Activity class called TextMessage, which should look something like this:

    public class TextMessage extends Activity
    {
      public void onCreate(Bundle savedInstanceState) {
       setContentView(R.layout.text);
       TextView message = (TextView)findViewById(R.id.message);
    
       Intent intent = getIntent();
       String bodys = intnet.getExtras().getString(thisClass.class.getName());
       message.setText(bodys);
    
    
     }
    

    This should do the trick for you.

    p.s. be sure to declare the TextMessage class in the AndroidManifest.xml file

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some problem with my open new window popup which it can read
I can open a new window using window.open() in ExternalInterface.call() but then I want
I know JavaScript can open a link in a new window but is it
from this thread thread i can open new window by using message this comment
How can I ensure that this does NOT open in a new window?? onclick=ob=this.form.table;window.open(ob.options[ob.selectedIndex].value)/>
Can someone explain to me how can I open a new tab from a
how can I assign a keyboard shortcut to open new window or make any
How can I open an image in a new window by using its id
Is there anyway that i can open a new window in the browser using
Using JavaScript, how can i open a new window (loading, say, http://www.google.com in the

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.