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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:48:42+00:00 2026-05-26T07:48:42+00:00

I have the following code in my activity: …… DataCell[i] = new TextView(context,null,R.style.TitleRow); DataCell[i].setText(data[i]);

  • 0

I have the following code in my activity:

......  
DataCell[i] = new TextView(context,null,R.style.TitleRow);
DataCell[i].setText(data[i]);
......

Here is my style.xml file, which is in res >> values folder:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="TitleRow" parent="@android:style/TextAppearance.Medium">
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:textColor">#A0A0A0</item>
        <item name="android:layout_marginTop">5dp</item>
        <item name="android:layout_marginBottom">5dp</item>
        <item name="android:paddingLeft">2dp</item>
        <item name="android:paddingRight">2dp</item>
    </style>
</resources>

No value is getting displayed..
But if I use DataCell[i] = new TextView(context) , its working fine. I know there is some problem with the fact that I am using null for attribute set. But after searching for a long time I am unable to find a perfect example of how to do it. I hope someone could clarify this to me once and for all.

  • 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-26T07:48:43+00:00Added an answer on May 26, 2026 at 7:48 am

    I usually end up creating a simple layout file only containing the element I want to instantiate ( TextView in your case ) that has the proper style applied and use the layout inflater to create the instance for me.

    layout file: styled_textview.xml

    <?xml version="1.0" encoding="utf-8"?>
    <TextView ... style="@+style/MyStyle" ... />
    

    code:

    activity.getLayoutInflater().inflate(R.layout.styled_textview, <root_node>, true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code on my web pages: <div class=rep_tb0 id=Activity style=display:none;> <div
I have the following code: FileOutputStream out = null; try { out = new
I have the following code in my activity: Cursor mCursor = managedQuery(ActivityColumns.CONTENT_URI, PROJECTION, null,
I have the following code in one activity: in= new Intent(ThisActivity.this,AnotherActivity.class); imgarr = new
I have following code class User attr_accessor :name end u = User.new u.name =
I have following code: public static void ProcessStep(Action action) { //do something here if
I have following code: public class readSensorsData extends Activity implements SensorListener { /** Called
I have the following code: $query = mysql_query(SELECT * FROM activity ORDER BY activity_time
I have the following code in Main.java : public class Main extends Activity implements
I have the following code: <div class=rep_tb0 style=width: 100%> <div class=rep_tr0 style=width: 100%> <div

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.