当我尝试将项目添加到xml时强制关闭

时间:2011-02-22 10:14:04

标签: java android eclipse

我在我的应用程序中使用基本列表视图格式创建了一系列listview,如下所示,我正在尝试为每个列表视图添加边框和标题,但每当我尝试向xml添加任何内容时,它都会强制关闭,我试过textview framelayout什么都行不通,有人可以帮忙吗?

package com.ff.org.p;

import android.app.ListActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.ff.org.R;
import com.ff.org.prrums.Anforums;
import com.ff.org.preps.Locare;

public class Ar extends ListActivity {

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        // Create an array of Strings, that will be put to our ListActivity
        String[] names = new String[] { "Forums", "Visitor Info", "Travel", "History", "Live Text" };
        ListView lv = getListView();
        lv.setBackgroundResource(R.drawable.background);
        lv.setCacheColorHint(00000000);

        this.setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, names));
    }

    // Get the item that was clicked
    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {
        if (position == 0) {
            Intent intent = new Intent(this, Arsenforums.class);
            startActivity(intent);
        }

        if (position == 1) {

            String url = "http://www.ide.com/nal/";
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            startActivity(i);
        } else if (position == 2) {
            Intent intent = new Intent(this, Locarse.class);
            startActivity(intent);
        }
    }
}

XML

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:gravity="center"
  android:padding="10dp"
  android:textColor="@color/black"
  android:textSize="21sp">
</TextView>

任何一个帮助

1 个答案:

答案 0 :(得分:0)