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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:06:03+00:00 2026-05-28T13:06:03+00:00

So, I decided to learn to write Android apps. I prefer learning by writing

  • 0

So, I decided to learn to write Android apps. I prefer learning by writing code so I setup my environment and dived in to Android!

And hit my head 🙂

I am trying to add import RelativeLayout as TableRows to a Table view.

This is my table layout which I want to re-use,

 <?xml version="1.0" encoding="utf-8"?>   
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/upload_list_table"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:stretchColumns="*" >

</TableLayout>

I included it i my my main activity with

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@+id/home_activity"
  android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical" >

<include android:id="@+id/homeActivityUploadList" layout="@layout/upload_list_table" />
</LinearLayout>

Then, I created my Row with RelativeLayout

<?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/upload_list_table_row_relative"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="6dip" >



<ImageView
    android:id="@+id/fileThumb"
    android:layout_width="90px"
    android:layout_height="fill_parent"
    android:layout_alignParentTop="true"
    android:layout_gravity="left"
    android:padding="2px"

    android:src="@drawable/nothumb" />

<TextView
    android:id="@+id/fileDescription"
    android:layout_width="fill_parent"
    android:layout_height="26dip"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_toRightOf="@id/fileThumb"
    android:ellipsize="marquee"
    android:singleLine="true"
    android:text="Desc" />


<TextView
    android:id="@+id/fileTitle"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@id/fileDescription"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_alignWithParentIfMissing="true"
    android:layout_toRightOf="@id/fileThumb"
    android:gravity="center_vertical"
    android:text="Title" />

 </RelativeLayout>

Now, I am trying this

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


    TableLayout tbl = (TableLayout)findViewById(R.id.homeActivityUploadList);
    RelativeLayout row = (RelativeLayout)findViewById(R.layout.upload_list_table_row_relative);

    tbl.addView(row);


}

But, i get NullPointerException. It can’t find

RelativeLayout row = (RelativeLayout)findViewById(R.layout.upload_list_table_row_relative);

I’ve also tried

RelativeLayout row = (RelativeLayout)findViewById(R.id.upload_list_table_row_relative);

What am I doing wrong?

Thanks

Log output

    01-24 11:30:15.757: D/dalvikvm(1625): GC_EXTERNAL_ALLOC freed 46K, 53% free    2539K/5379K, external 1625K/2137K, paused 68ms

01-24 11:30:15.877: D/dalvikvm(1625): GC_EXTERNAL_ALLOC freed 1K, 53% free 2538K/5379K, external 2250K/2810K, paused 58ms
01-24 11:30:15.967: D/AndroidRuntime(1625): Shutting down VM
01-24 11:30:15.967: W/dalvikvm(1625): threadid=1: thread exiting with uncaught exception (group=0x40015560)
01-24 11:30:15.977: E/AndroidRuntime(1625): FATAL EXCEPTION: main
01-24 11:30:15.977: E/AndroidRuntime(1625): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.*.HomeActivity}: java.lang.NullPointerException
01-24 11:30:15.977: E/AndroidRuntime(1625): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
01-24 11:30:15.977: E/AndroidRuntime(1625): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
01-24 11:30:15.977: E/AndroidRuntime(1625): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-24 11:30:15.977: E/AndroidRuntime(1625): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
01-24 11:30:15.977: E/AndroidRuntime(1625): at android.os.Handler.dispatchMessage(Handler.java:99)
01-24 11:30:15.977: E/AndroidRuntime(1625): at android.os.Looper.loop(Looper.java:123)
01-24 11:30:15.977: E/AndroidRuntime(1625): at android.app.ActivityThread.main(ActivityThread.java:3683)
01-24 11:30:15.977: E/AndroidRuntime(1625): at java.lang.reflect.Method.invokeNative(Native Method)
01-24 11:30:15.977: E/AndroidRuntime(1625): at java.lang.reflect.Method.invoke(Method.java:507)
01-24 11:30:15.977: E/AndroidRuntime(1625): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-24 11:30:15.977: E/AndroidRuntime(1625): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-24 11:30:15.977: E/AndroidRuntime(1625): at dalvik.system.NativeStart.main(Native Method)
01-24 11:30:15.977: E/AndroidRuntime(1625): Caused by: java.lang.NullPointerException
01-24 11:30:15.977: E/AndroidRuntime(1625): at android.view.ViewGroup.addView(ViewGroup.java:1821)
01-24 11:30:15.977: E/AndroidRuntime(1625): at android.widget.TableLayout.addView(TableLayout.java:403)
01-24 11:30:15.977: E/AndroidRuntime(1625): at android.view.ViewGroup.addView(ViewGroup.java:1808)
01-24 11:30:15.977: E/AndroidRuntime(1625): at android.widget.TableLayout.addView(TableLayout.java:394)
01-24 11:30:15.977: E/AndroidRuntime(1625): at com.*.onCreate(HomeActivity.java:23)
01-24 11:30:15.977: E/AndroidRuntime(1625): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-24 11:30:15.977: E/AndroidRuntime(1625): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
01-24 11:30:15.977: E/AndroidRuntime(1625): … 11 more

    android:ellipsize=
  • 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-28T13:06:04+00:00Added an answer on May 28, 2026 at 1:06 pm

    you must use LayoutInflater

    LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    RelativeLayout  row = (RelativeLayout ) layoutInflater.inflate(R.layout.upload_list_table_row_relative, null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to learn python, so I decided to write a script that could
I'm trying to learn Haskell, so I decided to write a simple program to
I have decided to learn Silverlight, but apart from knowing how to write apps,
Greetings, everyone. I'm trying to learn some Silverlight basics, and have decided to write
I've decided to learn about RSA encryption since learning about the vernal cipher in
I'm writing a hobby project wherein I write to .wav files. I decided that
Learn Twisted. I decided to write a server and client that once a second
I decided to learn a little bit android progrramming and by using Eclipse +
In my attempts to learn how to write Google Chrome extensions I decided to
I'm trying to learn asyncore module. So I decided to develop a chat program.

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.