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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:39:49+00:00 2026-05-30T01:39:49+00:00

I created a table view and display some text there with help of experts

  • 0

I created a table view and display some text there with help of experts in android.

Now i wish to push a new view when user click on each cell of a table view.

I created a new class within the same package named Newview.java.

The labels are displaying correctly in three different rows.

But when i click the first cell the program is crashing.

Can you please help me where im going wrong.

HelloTableLayoutActivity.java

  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.TextView;

  public class HelloTableLayoutActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        TextView name =  (TextView)findViewById(R.id.label);
        name.setOnClickListener(new View.OnClickListener(){

        public void onClick(View v) {
        Intent nameActivity =new Intent();
        nameActivity .setClass(getApplicationContext(), Newview.class);
        startActivity(nameActivity);

        }
      });
    }
}

Main.xml

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

    <TableRow>
        <TextView
            android:layout_column="1"
            android:text="@string/name"
            android:padding="3dip" />
        <TextView
            android:text="@string/initial"
            android:gravity="right"
            android:padding="3dip" />
    </TableRow>

    <TableRow>
        <TextView
            android:layout_column="1"
            android:text="@string/hometown"
            android:padding="3dip" />
        <TextView
            android:text="@string/state"
            android:gravity="right"
            android:padding="3dip" />
    </TableRow>   

</TableLayout>

Can anyone please help me how can i push a new view when click on the cell of table view in android.Thanks in advance.Hope for your 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-30T01:39:50+00:00Added an answer on May 30, 2026 at 1:39 am

    Declare your activity in the manifest like below:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.sweans.tb"
        android:versionCode="1"
        android:versionName="1.0" >
    
        <uses-sdk android:minSdkVersion="15" />
    
        <application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name" 
             >
            <activity
                android:label="@string/app_name"
                android:name=".HelloTableLayoutActivity">
                <intent-filter >
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
    
            <activity 
                android:name=".Newview"
                android:label="@string/app_name"
                >
            </activity>
    
        </application>
    
    </manifest>
    

    To add your further activities to the manifest, add them in your <application> tag as shown above with the Newview. So, that’s as far as your manifest goes. When it comes to code, there are a few things that you need to take care of.

    Firstly, whenever you want to display a new screen to the user, make it a point to convert the class into an Activity. You can do it as follows:

    public class Newview extends Activity
    {
     /** Called when the activity is first created. */
    
        @Override
        public void onCreate(Bundle savedInstanceState) 
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.foo);
        }
    }
    

    foo refers to an XML file name. This foo.xml which will be in your res/layout/ will contain another layout to display to your user. So, when you’re switching screens/activities, make sure you’ve your foo.xml filled with atleast a TextView so that you don’t get confused as to whether your app is working or not.

    One last thing. When you extend your class with Activity, make sure you import all related packages such as import android.app.Activity; for Activity and import android.os.Bundle; for public void onCreate(Bundle savedInstanceState). These are just examples.

    Hope this helps.

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

Sidebar

Related Questions

I am new to iPhone development. I have created a table view in a
I have a table view, with an added headerview created in IB to display
I have a dynamically created table which in the last <td> there is a
I created an app to connect to an existing sqlite db, and display some
I've created a table from a TcxGrid with a simple table view. The data
I want to display some data on table, let's call it TabeView app. So
I'm struggling to create a table view controller that has anything more than just
I used the Interface Builder to create a table view, to which I added
I am trying to create a pivot table type view in postgresql and am
I've created a view on 3 tables in my database, they are as follows:

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.