Did you add the new activity ("test") to the manifest?
What's in logcat?
BTW, you don't need to do your own try/catch blocks with error logging
just to see what's going on. Just use logcat.
-- Kostya
19.12.2010 19:59, apachetechnology пишет:
I am trying to start a activity from ListActivity but its crashing.
package net.apachetechnology.Organizer;
import android.R;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class Organizer extends ListActivity {
private ArrayAdapter<Item> m_adapterItems;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Item[] items = {
new Item(Task.class, "Add Task"),
new Item(test.class, "Testing"),
};
m_adapterItems = new ArrayAdapter<Item>(this,
R.layout.simple_list_item_1, items);
setListAdapter(m_adapterItems);
}
@Override
protected void onListItemClick(ListView l, View v, int position,
long id) {
//startActivity(m_adapterItems.getItem(position));
//m_adapterItems.getClass();
Intent intent = new Intent();
intent.setClass(Organizer.this, test.class);
startActivity(intent);
}
class Item extends Intent {
String s;
public Item(Class<?> c, String s) {
super(Organizer.this, c);
this.s = s;
}
@Override
public String toString() {
return s;
}
}
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++
package net.apachetechnology.Organizer;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class test extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState) {
try {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
catch (Exception e)
{
Log.e("ERROR", e.toString());
e.printStackTrace();
}
}
}
===========================================================================
<?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"
android:gravity="center_vertical|center_horizontal"
>
<TextView
android:text="Testing"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en