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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:39:21+00:00 2026-06-13T20:39:21+00:00

I have two methods: private void openPrivate(String target) { currentKeyWindows = target; Log.i(better,openPrivate +

  • 0

I have two methods:

private void openPrivate(String target) {
    currentKeyWindows = target;
    Log.i("better","openPrivate "+ target);
    if (windows.containsKey(currentKeyWindows)) {
    } else {
        tw = createTextView(currentKeyWindows);

        ActionBar.Tab newTab = getSupportActionBar().newTab();
        newTab.setText(currentKeyWindows);
        newTab.setTabListener(MainActivity.this);

        getSupportActionBar().addTab(newTab, true);
    }
}

private void jointochannel(String target) {
    currentKeyWindows = "#" + target;
    Log.i("better","jointochannel "+ target);
    if (windows.containsKey(currentKeyWindows)) {
    } else {
        tw = createTextView(currentKeyWindows);
        listofnicks.put(currentKeyWindows, new ArrayList<String>());
        nicklistadapter = new ArrayAdapter<String>(this, R.xml.mylistview, listofnicks.get(currentKeyWindows));
        nicklist.setAdapter(nicklistadapter);

                registerForContextMenu(nicklist);  


        ActionBar.Tab newTab = getSupportActionBar().newTab();
        newTab.setText(currentKeyWindows);
        newTab.setTabListener(MainActivity.this);

        getSupportActionBar().addTab(newTab, true);
        irc.addCommand(new Command(Command.JOIN_TO_CHANNEL, "JOIN " + currentKeyWindows));
    }
            channel = currentKeyWindows;
}

The second method works well. The first method (openPrivate) ends by null point exceptions at the line:

getSupportActionBar().addTab(newTab, true);

My AndroidManifest.xml:

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

What to do? Why the same code works differently?
Regards, Denis.

LogCat:

11-04 17:06:57.241: E/AndroidRuntime(4696): FATAL EXCEPTION: main
11-04 17:06:57.241: E/AndroidRuntime(4696): java.lang.NullPointerException
11-04 17:06:57.241: E/AndroidRuntime(4696):     at android.widget.ArrayAdapter.getCount(ArrayAdapter.java:291)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at android.widget.ListView.setAdapter(ListView.java:454)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at ru.startandroid.develop.MainActivity.onTabSelected(MainActivity.java:427)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at com.actionbarsherlock.internal.app.ActionBarImpl.selectTab(ActionBarImpl.java:526)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at com.actionbarsherlock.internal.app.ActionBarImpl.addTab(ActionBarImpl.java:452)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at ru.startandroid.develop.MainActivity.openPrivate(MainActivity.java:382)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at ru.startandroid.develop.MainActivity.onContextItemSelected(MainActivity.java:100)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at android.app.Activity.onMenuItemSelected(Activity.java:2209)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at com.android.internal.policy.impl.PhoneWindow$ContextMenuCallback.onMenuItemSelected(PhoneWindow.java:2785)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at com.android.internal.view.menu.MenuDialogHelper.onClick(MenuDialogHelper.java:137)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:873)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at android.widget.AdapterView.performItemClick(AdapterView.java:284)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at android.widget.ListView.performItemClick(ListView.java:3513)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at android.widget.AbsListView$PerformClick.run(AbsListView.java:1812)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at android.os.Handler.handleCallback(Handler.java:587)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at android.os.Handler.dispatchMessage(Handler.java:92)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at android.os.Looper.loop(Looper.java:130)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at android.app.ActivityThread.main(ActivityThread.java:3683)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at java.lang.reflect.Method.invokeNative(Native Method)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at java.lang.reflect.Method.invoke(Method.java:507)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-04 17:06:57.241: E/AndroidRuntime(4696):     at dalvik.system.NativeStart.main(Native Method)

onTabSelected(Tab tab, FragmentTransaction ft):

    public void onTabSelected(Tab tab, FragmentTransaction ft)
{
    currentKeyWindows = tab.getText().toString();

    mScrollView.removeAllViews();
    mScrollView.addView(this.windows.get(this.currentKeyWindows));
    scrollToBottom();


    nicklistadapter = new ArrayAdapter<String>(this, R.xml.mylistview, listofnicks.get(currentKeyWindows));
    nicklist.setAdapter(nicklistadapter);

    registerForContextMenu(nicklist);  
    channel=currentKeyWindows;

}
  • 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-13T20:39:22+00:00Added an answer on June 13, 2026 at 8:39 pm

    Judging from your LogCat it appears that the array you pass to your adapter is null:

    nicklistadapter = new ArrayAdapter<String>(this, R.xml.mylistview, listofnicks.get(currentKeyWindows));
    

    I would verify that listofnicks.get(currentKeyWindows) returns a valid result.

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

Sidebar

Related Questions

I have two methods declared public void MethodA(object o, Action<string> action) { } public
I have two methods: private void RvListen_OPT() private void RvListen_FUT() On a certain event,
I have two methods on my Sender class: public void SendMessage(OutgoingMessage msg) { try
Total OO noob question here. I have these two methods in a class private
I have two classes public class PrepaidPackage { private String name; private String serviceClassID;
I have two methods -a and -b. -a calls sometimes -b, and -b sometimes
I have two methods, the first needs a Map<ItemA, ItemB> the second a Map<ItemA
I have two methods, one called straight after another, which both throw the exact
I have two methods, one that I use to convert an image to a
lets say I have two methods in my controller to support both json 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.