调试模式工作,但运行给了Android错误

时间:2014-04-12 20:24:09

标签: android android-listview

我将我的真实活动减少到导致错误的非常基本的活动,当我在&#34中运行我的代码时,运行"它说应用程序停止了,但是当我在" debug"中运行我的代码时它运行没有错误。无法找到原因??

以下是我的活动:

public class Settings extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.scroldowndeneme);

        ListView listView = (ListView)findViewById(R.id.listViewdeneme);
        MyAdapter adapter = new MyAdapter(Settings.this, R.layout.rowwithimage, new String[]{"singlesamplefortry"});
        listView.setAdapter(adapter);
        adapter.notifyDataSetChanged();
    }

    public class MyAdapter extends ArrayAdapter<String> {

        public MyAdapter(Context context, int textViewResourceId,   String[] objects) {
            super(context, textViewResourceId, objects);
        }

        @Override
        public View getDropDownView(int position, View convertView,ViewGroup parent) {
            return getCustomView(position, convertView, parent);
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            return getCustomView(position, convertView, parent);
        }

        public View getCustomView(int position, View convertView, ViewGroup parent) {

            LayoutInflater inflater=getLayoutInflater();
            View row=inflater.inflate(R.layout.rowwithimage, parent, false);
            ImageView as = (ImageView) row.findViewById(R.id.userpictureofrowwithimage);
            as.setImageResource(R.drawable.profilepicturesmall);

            return row;
        }
    }
}

以下是scroldowndeneme的布局:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

    <ListView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/listViewdeneme"/>
</LinearLayout>

这是rowwithimage的布局:

<?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="wrap_content"
                android:orientation="horizontal"
                android:padding="3dip"
        >
    <ImageView
            android:id="@+id/userpictureofrowwithimage"
            android:layout_height="50dp"
            android:layout_width="50dp"/>
    <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
        <TextView
                android:padding="3dip"
                android:textStyle="bold"
                android:id="@+id/company"
                android:text="CoderzHeaven"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:gravity="center"/>
        <TextView
                android:padding="2dip"
                android:id="@+id/sub"
                android:text="Heaven of all working codes"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1" android:gravity="center"/>
    </LinearLayout>
</LinearLayout>

0 个答案:

没有答案