• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Basic help about UI

Zookey

Lurker
First of all, hi to all of you guys...

I am new to Android app development and I need some very basic help.

Here is my graphical layout.



Here is main.xml file code:

Code:
<?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:layout_width="wrap_content"
		android:layout_height="wrap_content" android:text="@string/tvNaslov"
		android:textSize="25dp" android:gravity="center"
		android:layout_gravity="center" android:id="@string/tvNaslov"></TextView>
	<EditText android:layout_width="match_parent" android:text="@string/editStatus"
		android:hint="@string/editStatus1" android:layout_height="fill_parent"
		android:layout_weight="1" android:id="@string/editStatus"></EditText>
	<Button android:text="@string/btnKolacic" android:id="@string/btnKolacic"
		android:layout_height="wrap_content" android:layout_width="match_parent"></Button>
</LinearLayout>

And here is Java code:

Code:
package com.test.test;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class Test extends Activity implements OnClickListener {
	EditText editStatus;
	Button btnKolacic;
	TextView tvNaslov;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        btnKolacic.setOnClickListener(this);
    }
	@Override
	public void onClick(View v) {
		
		
	}
}

This program actually doesn't doing anything for now. Because I get error when I try to run it. I dont get it where is error. :/ Hope you can help me.

ERROR



DDMOS

Code:
[2011-06-30 17:35:48 - ddms]null
java.lang.NullPointerException
	at com.android.ddmlib.Client.sendAndConsume(Client.java:572)
	at com.android.ddmlib.HandleHello.sendHELO(HandleHello.java:142)
	at com.android.ddmlib.HandleHello.sendHelloCommands(HandleHello.java:65)
	at com.android.ddmlib.Client.getJdwpPacket(Client.java:671)
	at com.android.ddmlib.MonitorThread.processClientActivity(MonitorThread.java:317)
	at com.android.ddmlib.MonitorThread.run(MonitorThread.java:263)
 
you didn't assign the button object in the java code to any value [didn't connect it to the one form the xml]
after:
Code:
setContentView(R.layout.main);
add this
Code:
[FONT=monospace]btnKolacic = (Button) findViewById(R.id.btnKolacic);[/FONT]
 
Back
Top Bottom