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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:48:05+00:00 2026-05-27T22:48:05+00:00

Can someone tell me why the code from Starting new code onwards does not

  • 0

Can someone tell me why the code from “Starting new code” onwards does not work?
The onClick method in the click event listeners does not get called and even the text change for the label does not take place.

The log shows ID’s for the buttons so something is being found. The buttons and label are in a TableLayout which is inside a LinearLayout.

The onCreate method where I’m binding the buttons.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.contact_list);

    setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);

    mContactList = (ListView) findViewById(R.id.contactList);
    mInputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    mApplicationData = (GlobalApplicationData) getApplication();

    setTitle(mApplicationData.getAppTitle());
    mSettings = mApplicationData.getSettings();
    initializedEncryptionKey();

    mContactsDB = mApplicationData.getContactsDB();

    mXmppModalUI =  new XmppModalUI(mInputManager);
    mXmppModalUI.initializeModalUI(this, mSettings, this);

    mApplicationData.getPersistentXMPP().setModalUI(mXmppModalUI);
    mApplicationData.getPersistentXMPP().setContactListCallback(this);

    mApprater = new Appirater(this, mSettings);

    if (mApplicationData.getUpdateChecker() == null && mApplicationData.getUpdateCheckerUrl() != null) {
        mApplicationData.setUpdateChecker(new UpdateChecker(getApplicationContext(), mApplicationData.getUpdateCheckerUrl()));
    }

    //starting new code
    Toast.makeText(getApplicationContext(), "Starting Ali's Code", Toast.LENGTH_SHORT).show();

    TableLayout header = (TableLayout) findViewById(R.id.headerLayout);
    Log.d("TableLayout",((header == null)?"NOT FOUND":"FOUND "+header.getId()));

    final TextView labelHeader = (TextView) header.findViewById(R.id.headerText);
    labelHeader.setText("Jump");

    final ImageButton btnSettings = (ImageButton) header.findViewById(R.id.btnSettings);
    btnSettings.setClickable(true);
    Log.d("Settings Button",((btnSettings == null)?"NOT FOUND":"FOUND "+btnSettings.getId()));
    btnSettings.setOnClickListener(new View.OnClickListener()
    {
        public void onClick(View v)
        {
            Log.d("OnClick","Here");
            // Perform action on clicks
            Toast.makeText(getApplicationContext(), "Settings", Toast.LENGTH_SHORT).show();
            startGlobalSettings();
        }
    });

    final ImageButton btnAdd = (ImageButton) header.findViewById(R.id.btnAdd);
    btnAdd.setClickable(true);
    Log.d("Add Button",((btnAdd == null)?"NOT FOUND":"FOUND "+btnAdd.getId()));
    btnAdd.setOnClickListener(new View.OnClickListener()
    {
        public void onClick(View v)
        {
            Log.d("OnClick","Here");
            // Perform action on clicks
            Toast.makeText(getApplicationContext(), "ADD", Toast.LENGTH_SHORT).show();
            showDialog(DialogIds.ADD_CONTACT);
        }
    });

}

The layout (contact_list.xml):

<TableLayout
    android:id="@+id/headerLayout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:stretchColumns="1" >

    <TableRow>

        <ImageButton
            android:id="@+id/btnSettings" 
            android:gravity="left"
            android:padding="3dip"
            android:src="@drawable/ic_menu_add"
            android:hint="@string/label_settings" />

        <TextView
            android:id="@+id/headerText"
            android:gravity="center"
            android:padding="3dip"
            android:text="Blank" 
            android:height="50dip"/>

        <ImageButton
            android:id="@+id/btnAdd"
            android:background="@drawable/disconnectbutton"
            android:gravity="right"
            android:padding="3dip"
            android:src="@drawable/ic_menu_add"
            android:hint="@string/label_add" />

    </TableRow>

</TableLayout>

<ListView
    android:id="@+id/contactList"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:background="@color/transparent"
    android:cacheColorHint="#00000000" >
</ListView>

UPDATE
I tried removing the header part, as a matter of fact, I add the header part because it wasn’t working before when I simply called findViewById()

  • 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-27T22:48:06+00:00Added an answer on May 27, 2026 at 10:48 pm

    remove this header.findViewById(R.id.btnSettings);

    ImageButton btnSettings = (ImageButton)findViewById(R.id.btnSettings);
    

    //you are not inflating the any layout, already your content view has layout contact_list.xml in this only your buttons and label are there.

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

Sidebar

Related Questions

Can someone tell me how to access a sqlite3 database from perl. the code
can someone tell me how to convert code templates from xcode3 to xcode4? I
Can someone tell me what the code equivelant in VB.Net to this C# code
Can someone please tell me how I can implement the following line of pseudo-code.
Can someone tell me why this processes all the files and then does it
can someone tell me how to insert the selected text not the value of
Can someone tell me why this code produces error? The C# code DateTime now
Can someone tell me how to write code that pushes the content of a
I have found this Regex extractor code in C#. Can someone tell me how
Can someone tell me how to modify the code below so that it filters

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.