hey guys im new a little new to the forum and ive built several android applications before however this one seems to be a pain in the but, Im building my own Dialog box and working on handling a touch event, ive tried lots of things but for some reason i keep getting this error
Im just wanting an on touch listener so i can start a new activity or even a sum activity it will be to open a gallery where users will be able to select default avatars or pick from their images or take a picture.
here's the code maybe someone could hep me
Code:
10-27 21:52:37.965: WARN/dalvikvm(635): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
10-27 21:52:37.985: ERROR/AndroidRuntime(635): FATAL EXCEPTION: main
10-27 21:52:37.985: ERROR/AndroidRuntime(635): java.lang.ClassCastException: android.widget.LinearLayout
10-27 21:52:37.985: ERROR/AndroidRuntime(635): at com.appsand.proto.ListViewDialog$ListItemsAdapter$1.onItemClick(ListViewDialog.java:70)
10-27 21:52:37.985: ERROR/AndroidRuntime(635): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
10-27 21:52:37.985: ERROR/AndroidRuntime(635): at android.widget.ListView.performItemClick(ListView.java:3382)
10-27 21:52:37.985: ERROR/AndroidRuntime(635): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
10-27 21:52:37.985: ERROR/AndroidRuntime(635): at android.os.Handler.handleCallback(Handler.java:587)
10-27 21:52:37.985: ERROR/AndroidRuntime(635): at android.os.Handler.dispatchMessage(Handler.java:92)
10-27 21:52:37.985: ERROR/AndroidRuntime(635): at android.os.Looper.loop(Looper.java:123)
10-27 21:52:37.985: ERROR/AndroidRuntime(635): at android.app.ActivityThread.main(ActivityThread.java:4627)
10-27 21:52:37.985: ERROR/AndroidRuntime(635): at java.lang.reflect.Method.invokeNative(Native Method)
10-27 21:52:37.985: ERROR/AndroidRuntime(635): at java.lang.reflect.Method.invoke(Method.java:521)
10-27 21:52:37.985: ERROR/AndroidRuntime(635): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-27 21:52:37.985: ERROR/AndroidRuntime(635): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-27 21:52:37.985: ERROR/AndroidRuntime(635): at dalvik.system.NativeStart.main(Native Method)
10-27 21:52:37.995: WARN/ActivityManager(61): Force finishing activity com.appsand.proto/.ListViewDialog
10-27 21:52:38.515: WARN/ActivityManager(61): Activity pause timeout for HistoryRecord{43f8e9e0 com.appsand.proto/.ListViewDialog}
10-27 21:52:48.015: WARN/ActivityManager(61): Launch timeout has expired, giving up wake lock!
10-27 21:52:48.547: WARN/ActivityManager(61): Activity idle timeout for HistoryRecord{43f89460 com.appsand.proto/.AppSandUserSettingsActivity}
10-27 21:52:58.551: WARN/ActivityManager(61): Activity destroy timeout for HistoryRecord{43f8e9e0 com.appsand.proto/.ListViewDialog}
here's the code maybe someone could hep me
Code:
package com.appsand.proto;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
public class ListViewDialog extends Activity
{
private List<String> listItems = new ArrayList<String>();
private ListItemsAdapter adapter = null;
private TextView text;
private ImageView icon;
private ListView list;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View layout = inflater.inflate(R.layout.dialog, (ViewGroup) findViewById(R.id.root));
setContentView(layout);
listItems.add(getResources().getString(R.string.default_avatar));
listItems.add(getResources().getString(R.string.user_avatar));
list = (ListView) findViewById(R.id.list);
adapter = new ListItemsAdapter(listItems);
list.setAdapter(adapter);
}
private class ListItemsAdapter extends ArrayAdapter<String>
{
public ListItemsAdapter(List<String> items)
{
super(ListViewDialog.this, android.R.layout.simple_list_item_1, items);
}
public View getView(int position, View convertView, ViewGroup parent)
{
LayoutInflater inflater = getLayoutInflater();
convertView = inflater.inflate(R.layout.dialog_items, null);
text = (TextView) convertView.findViewById(R.id.DialogText);
text.setText(listItems.get(position));
convertView.setTag(text);
icon=(ImageView)convertView.findViewById(R.id.DialogImage);
if (listItems.get(position).equals(getResources().getString(R.string.default_avatar)))
icon.setImageResource(R.drawable.default01);
else
icon.setImageResource(R.drawable.default04);
return convertView;
}
}
}