Hi guys,
This is my first post of many, I need help. Whenever I try to compile the first program I've ever written for android the program I've made crashes instantly on the emulator and I get the "Force close option".
I'm really stuck, how do I fix this error? I'm pretty certain it's nothing to do with my code but I'll post my code here anyways.
If anyone could help me over TeamViewer, that would be brilliant.
[spoiler]
Java:
[/spoiler]package bradley.flay.is.a.baws; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; public class BradleysprojectActivity extends Activity { //Global Variables int counter = 0; Button button1 = (Button) findViewById(R.id.bAdd);; Button button2 = (Button) findViewById(R.id.bSub); TextView textview1 = (TextView) findViewById(R.id.tvTheNumIsOne); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); button1.setOnClickListener(new View.OnClickListener(){ public void onClick(View v) { counter++; textview1.setText("The total is " + counter); }; }); button2.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { counter--; textview1.setText("The total is " + counter); } }); } }
[spoiler]
XML
[/spoiler]<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="The total is 0" android:id="@+id/tvTheNumIsOne" android:textSize="30dp" android:gravity="center" /> <Button android:layout_width="200dp" android:layout_height="45dp" android:text="Add one" android:id="@+id/bAdd" /> <Button android:layout_width="200dp" android:layout_height="45dp" android:text="Subtract one" android:id="@+id/bSub" android:gravity="center" /> </LinearLayout>
EDIT: Just realised I have this error when trying to debug on the SDK:
Error:
Can't bind to local 8615 for debugger
Hope you can help me with this,
Ralbeyd