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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:04:46+00:00 2026-05-29T06:04:46+00:00

In Android in litemitemclick I am using this piece of code: TextView tvofpostedText =

  • 0

LOgCat..In Android in litemitemclick I am using this piece of code:

TextView tvofpostedText = (TextView)findViewById(R.id.postedgtext);
    @Override
                public void onItemClick(AdapterView<?> arg0, View arg1, int pos,
                        long arg3) {



    final AlertDialog.Builder builder = new AlertDialog.Builder(
                        DemoPage2.this);
                LayoutInflater factory = LayoutInflater.from(DemoPage2.this);

                final View textEntryView = factory.inflate(
                        R.layout.layoutforalertdialog, null);

                // builder.setMessage("" + s.get(pos))
                try {
                    tvofpostedText.setText("username:" + s.get(pos));
                } catch (Exception e) {
                    // do nothing
                }
                builder.setMessage("" + username + (CharSequence) s.get(pos))
                        .setCancelable(true)
                        .setTitle("post Detail")
                        .setView(textEntryView)

                        .setPositiveButton("View Comments",
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog,
                                            int id) {
                                        // ListViewActivity.this.finish();

                                    }
                                })
                        .setNegativeButton("Cancel",
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog,
                                            int id) {
                                        dialog.cancel();
                                    }
                                })
                        .setNeutralButton("Post Comments",
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog,
                                            int whichButton) {
                                    }
                                });
                AlertDialog alert = builder.create();
                alert.show();
                tvofpostedText.setText("username:" + s.get(pos));
            }

        });

s is an ArrayList. I am getting a NullPointerException on the line tvofpostedText.setText("username:" + s.get(pos));. At least “username” should have been set as text even if s.get(pos) is null. Please help me out.In the logcat i am getting null pointer exception.tvofpostedText is comming null.Plese HELP>

  • 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-29T06:04:47+00:00Added an answer on May 29, 2026 at 6:04 am

    Well, you’ve got two possibilites, neither of which anyone here can determine with the code you’ve given.

    1. tvofpostedText is null.
    2. s is null.

    Figure out which one is null and fix that. You don’t show where either of these is declared, but that’s the only two possibilities given the line it’s crashing at.

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

Sidebar

Related Questions

Android: public class LocationService extends Service { @Override public void onStart(Intent intent, int startId)
Android: I am using following code to insert image into album According to description
Android Java project, minimal code to reproduce the problem: Constants.java : package alex.restaurantfinder; public
Android: i am using gps check box in my application, which user check this
Android Code Style Guide defines Android Code Style Rules. To conform to these rules
Android beginner, Can anybody guide me on this ? I do have the distance,
Android APK-Files are not binaries but byte-code-files. So is it possible to install the
Android SDK Manager complains WARNING: Java not found in your path. Instead of using
android.text.format.DateFormat specifies that using the format string 'a' should yield 'a' or 'p' and
android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed error in my application and not sure why.

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.