Android OS Forum banner

Please Help (Application Development)

872 Views 1 Reply 2 Participants Last post by  linuxmotion
Im trying to develop an application and Im having trouble executing a function when a button is pressed. I have my main.xml for the button setup like this:

and my Activity setup like this:

package com.netbuilder;

import java.io.IOException;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class NetBuilderActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public int send() {
return 1;
}

}

My problem is when I press the button the application force closes on me. Obviously I dont want the send function to return 1. I want it to execute a shell command but Im trying to take it one step at a time. I'm completely new to Java.

Any help would be appreciated.
See less See more
1 - 2 of 2 Posts
tcpninja said:
Im trying to develop an application and Im having trouble executing a function when a button is pressed. I have my main.xml for the button setup like this:

and my Activity setup like this:

package com.netbuilder;

import java.io.IOException;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class NetBuilderActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public int send() {
return 1;
}

}

My problem is when I press the button the application force closes on me. Obviously I dont want the send function to return 1. I want it to execute a shell command but Im trying to take it one step at a time. I'm completely new to Java.

Any help would be appreciated.
You still need to define your button In the onCreate() method. I think.
Ex.
Button button = this.findviewbyid(R.id.button1);

I can't remember if it should go after or before setContentView() method in the onCreate() method.

Remember you can use 'adb logcat' to view the logs as your running/debugging your app. Its very helpful.

Sent from my Incredible using Tapatalk
1 - 2 of 2 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top