75329

Main Activity not shown in Android

Question:

I have an application in Android, I've changed the main Activity, and now nothing is showing up when I launch it. I don't know what could be wrong. Please help.

Main.xml

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/text1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <Button android:id="@+id/btnCrash" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/btnCrash" /> </LinearLayout>

Manifest.xml

<?xml version="1.0" encoding="utf-8"?> <manifest package="gdpTesis.client" android:versionCode="1" android:versionName="1.0" xmlns:android="http://schemas.android.com/apk/res/android"> <application android:icon="@drawable/icon" android:label="@string/app_name" android:name="gdpTesis.client.main.GdpTesisApplication"> <activity android:name=".main.GdpTesisMainActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>

The Activity

package gdpTesis.client.main; import gdpTesis.client.R; import android.app.Activity; import android.os.Bundle; public class GdpTesisMainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } }

Answer1:

I do not fully understand your naming conventions. The Activity package and name is

gdpTesis.client.main GdpTesisMainActivity

The Manifest package and name is

gdpTesis.client .main.GdpTesisMainActivity

I do not understand the need for

import gdtTesis.client.R

Consider:

Activity

package gdpTesis.client class GdpTesis

Manifest

package gdpTesis.client Activity name GdpTesis

and delete the Manifest Application name and import gdpTesis.client.R

Answer2:

I CAN'T BELIEVE IT! I'm with the emulator, and I don't have an Android phone, so I expected after running the application, see it in the emulator screen, but it was locked, and it doesn't unlock by itself, so just unlocking it with the mouse...showed the activity. sorry! and thanks!

Recommend

  • How to identify id of a view for a range of table cells within linear layout
  • How to setup night mode drawables to work as expected
  • PreparedStatement - how specify to use default value of column
  • Removing an XWPFParagraph keeps the paragraph symbol (¶) for it
  • JavaFX scrollbar customize. Eliminate extra square, when both scrollbars are activated
  • Strange behavior on div/child with font-size 0 (zero)
  • View disappears after setting height of gridLayout to wrap_content
  • MonoDroid - setting background color from colors.xml throws InvalidOperationException
  • Clustering algorithm with different epsilons on different axes
  • Bind two JSF input fields with single property of backing bean
  • Vertical align DIVs
  • Overlapping ImageView in RelativeView
  • Android custom dialog linearlayout size same as dialogs bg image
  • Android : Strike out Text with bold or thicker line than default STRIKE_THRU_TEXT_FLAG
  • Background image crashes android
  • How can I stop the scrollbar from displacing my page?
  • How to automatically pop-up keyboard?
  • Float Label hint (TextInputLayout) not works with Android Data Binding
  • Socket io in node app on google app engine
  • Android Custom dialog inflating from layout - alignment issue
  • EditText ignores the ImeActionLabel
  • jqPlot date axis - bars drawn on wrong day?
  • Gray line inside cardview :)?
  • my tic-tac-toe program in matlab does not work [closed]
  • C# List of Panels
  • How Lists (specifically, RecyclerView with CardViews) in Android work
  • Android fill_parent issue
  • How to draw moving and Running sine wave chart using JFree chart in java?
  • Validaiting emails with Net.Mail MailAddress
  • MySQL WHERE-condition in procedure ignored
  • jquery mobile loadPage not working
  • Web-crawler for facebook in python
  • Properly structure and highlight a GtkPopoverMenu using PyGObject
  • how to add data labels for bar graph in matlab
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • trying to dynamically update Highchart column chart but series undefined
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • apache spark aggregate function using min value
  • Sorting a 2D array using the second column C++
  • java string with new operator and a literal