Note that there are some explanatory texts on larger screens.

plurals
  1. PODefining layout for activity in android app
    primarykey
    data
    text
    <p>I am building and android app and have created the login screen. The next screen will show the logged in user a set of options from which he has to choose one. </p> <p>The second activity is started from the <code>onPostExecute</code> method of an <code>AsyncTask</code> using the <code>startActivity(intent)</code> code.</p> <pre><code>Intent intent = null; intent = new Intent(context, DisplayMessageActivity.class); context.startActivity(intent); </code></pre> <p>I am trying to build the UI for this screen using the .xml file <code>activity_display_message.xml</code>. The entry for this has been made to the manifest file. Any of the layout attributes that I am specifying in this .xml file are not getting applied. Any help in this regard is highly appreciated. For example using the code below I am unable to get the background color that I have set. This works fine with the .xml that I have for my main activity.</p> <p>The onCreate function for my DisplayMessageActivity class is</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_display_message); Intent intent = getIntent(); String message = intent.getStringExtra(CommonStaticValues.EXTRA_MESSAGE); TextView textView = new TextView(this); textView.setTextSize(40); textView.setText(message); setContentView(textView); } </code></pre> <p>The complete <code>activity_display_message.xml</code> file is</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/background_color"&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="@string/hello_world" tools:context=".DisplayMessageActivity" /&gt; &lt;/RelativeLayout&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload