Hi friends,
Myself *Sumanta* is facing problem with solving a
compilation error in *Android Studio 2.2*. The source code is as below:
*Android App development Program*
*1) *
* Code in Main activity*
*package* com.example.hello_android_sanfoundry;
*import* android.os.Bundle;
*import* android.app.Activity;
*import* android.view.Menu;
*public* *class* MainActivity *extends* Activity {
@Override
*protected* *void* onCreate(Bundle savedInstanceState) {
*super*.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
*public* *boolean* onCreateOptionsMenu(Menu menu) {
*// Inflate the menu; this adds items to the action bar if it is
present.*
getMenuInflater().inflate(R.menu.main, menu);
*return* *true*;
}
}
*2) **XML layout code*
*<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
*>*
*<!-- This is a comment -->*
*<!-- Create your comments like this -->*
*<TextView*
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_alignParentTop="true"
android:layout_marginTop="18dp"
android:text="@string/hello_sanfoundry_android" */>*
*<TextView*
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="53dp"
android:text="This is a Large Text View"
android:textAppearance="?android:attr/textAppearanceLarge" */>*
*<TextView*
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:layout_marginTop="16dp"
android:text="This is Medium Text View"
android:textAppearance="?android:attr/textAppearanceMedium" */>*
*<TextView*
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView3"
android:layout_below="@+id/textView3"
android:layout_marginTop="14dp"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall" */>*
*<Button*
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView4"
android:layout_below="@+id/textView4"
android:layout_marginTop="16dp"
android:text="Button" */>*
*<ToggleButton*
android:id="@+id/toggleButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button2"
android:layout_alignBottom="@+id/button2"
android:layout_alignParentRight="true"
android:text="ToggleButton" */>*
*<Button*
android:id="@+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/button1"
android:layout_centerHorizontal="true"
android:text="Small Button" */>*
*<CheckBox*
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/toggleButton1"
android:layout_below="@+id/toggleButton1"
android:layout_marginTop="93dp"
android:text="CheckBox" */>*
*<CheckedTextView*
android:id="@+id/checkedTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/checkBox1"
android:layout_alignBottom="@+id/checkBox1"
android:layout_alignLeft="@+id/button1"
android:text="CheckedTextView" */>*
*<RadioButton*
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/checkedTextView1"
android:layout_below="@+id/checkBox1"
android:layout_marginTop="34dp"
android:text="RadioButton" */>*
*<RadioButton*
android:id="@+id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/radioButton1"
android:layout_below="@+id/radioButton1"
android:text="RadioButton" */>*
*</Relative Layout**>*
*3) **Hello World Program*
*<?**xml version=**"1.0" **encoding=**"utf-8"*
*?> *<*RelativeLayout **xmlns:**android**=*
*"http://schemas.android.com/apk/res/android" **xmlns:**tools**=*
*"http://schemas.android.com/tools" **android**:id=*
*"@+id/activity_main" **android**:layout_width=*
*"match_parent" **android**:layout_height=*
*"match_parent" **android**:paddingBottom=*
*"@dimen/activity_vertical_margin" **android**:paddingLeft=*
*"@dimen/activity_horizontal_margin" **android**:paddingRight=*
*"@dimen/activity_horizontal_margin" **android**:paddingTop=*
*"@dimen/activity_vertical_margin" **tools**:context=*
*"helloworld.example.com.helloworld.MainActivity"*>
<
*TextView **android**:layout_width=*
*"wrap_content" **android**:layout_height=*
*"wrap_content" **android**:text=**"Bluetooth File Transfer" */>
</*RelativeLayout*>
*4) **Printing Text*
//*******************************************************************
// NOTE: please read the 'More Info' tab to the right for shortcuts.
//*******************************************************************
import java.lang.Math; // headers MUST be above the first class
// one class needs to have a main() method
public class HelloWorld
{
// arguments are passed using the text field below this editor
public static void main(String[] args)
{
OtherClass myObject = new OtherClass("Hello World!");
System.out.print(myObject);
}
}
// you can add other public classes to this editor in any order
public class OtherClass
{
private String message;
private boolean answer = false;
public OtherClass(String input)
{
message = "Why," + input + "Isn't this something?";
}
public String toString()
{
return message;
}
}
On compilation of the above code the following error is obtained :
"*Error parsing XML: no element found*".
So I request your suggestions on the above issue.
Thanks & Regards.
--
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-developers/a5a311bc-eeb0-420a-bd18-ce9e1b1baa52%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.