October 24th, 2011, 05:44 PM
|
#1 (permalink)
|
|
New Member
Join Date: Oct 2011
Posts: 8
Device(s):
Thanks: 6
Thanked 0 Times in 0 Posts
|
Force closes before even opening
Hey guys, I'm working on this new app, and it's force closing before it even opens, any idea as to why it's force closing? (I've tried this app on my samsung transform and my motorola xoom yesterday, both worked, and them i added the image button inplace of the regular button, and now it won't work. here are my files;
Main.xml
Code:
<?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="horizontal" >
<EditText
android:id="@+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine" >
<requestFocus />
</EditText>
<ImageButton
android:id="@+id/button1"
android:src="@drawable/pencil"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#000000" >
</ImageButton>
<ListView
android:id="@+id/listView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
.java file
Code:
package com.sevengangs.notetoself;
import java.util.ArrayList;
import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
public class NoteToSelfActivity extends Activity {
final ArrayList<String> noteList = new ArrayList<String>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setRequestedOrientation(
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setContentView(R.layout.main);
ListView view1 = (ListView) findViewById(R.id.listView1);
final EditText editText1 = (EditText) findViewById(R.id.editText1);
final ArrayAdapter<String> aa;
aa = new ArrayAdapter<String>(this, R.layout.custom_list_item, R.id.noteText, noteList);
view1.setAdapter(aa);
Button button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
noteList.add(0, editText1.getText().toString());
editText1.setText("");
}
});
}
}
My custom list
Code:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/noteText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#00FF33"
android:textSize="20px"
android:gravity="center_horizontal" >
</TextView>
Thank you in advance!
|
|
|