Android ListView怪异的行为

Android ListView怪异的行为,android,listview,Android,Listview,我正在尝试通过广播在listview表单服务中获取呼叫和sms日志。 问题是,当应用程序运行时,会出现一个空的listview,其中每个元素都有水平线。当您单击任何元素时,其中的数据将闪烁,当您松开单击按钮时,listview将再次变为空白 请帮帮我,我哪里做错了 LogServiceActivity.java package com.logservice; import java.util.ArrayList; import android.os.Bundle; import andro

我正在尝试通过广播在listview表单服务中获取呼叫和sms日志。 问题是,当应用程序运行时,会出现一个空的listview,其中每个元素都有水平线。当您单击任何元素时,其中的数据将闪烁,当您松开单击按钮时,listview将再次变为空白

请帮帮我,我哪里做错了

LogServiceActivity.java

package com.logservice;

import java.util.ArrayList;

import android.os.Bundle;

import android.app.ListActivity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.view.Menu;
import android.widget.ArrayAdapter;

public class LogServiceActivity extends ListActivity {

    public MyResultReceiver mReceiver;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_log_service);

        //start the service
        mReceiver = new MyResultReceiver();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(ServiceClass.MY_ACTION);
        registerReceiver(mReceiver, intentFilter);

        startService(new Intent(getApplicationContext(), ServiceClass.class));
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_log_service, menu);
        return true;
    }

    @Override
    protected void onStop() {
        unregisterReceiver(mReceiver);

        super.onStop();
    }

    public class MyResultReceiver extends BroadcastReceiver {
        ArrayList<String> callList = new ArrayList<String>();

        @Override
        public void onReceive(Context context, Intent intent) {
            String log = intent.getStringExtra("DATAPASSED");
            callList.add(log);
            setListAdapter(new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, callList));
        }
    }
}
ServiceClass.java:

package com.logservice;

import java.text.DateFormat;

import android.app.Service;
import android.content.Intent;
import android.database.Cursor;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;

public class ServiceClass extends Service {
      Intent intent = new Intent();

    private static final String TAG = null;
    final static String MY_ACTION = "My ACTION";

    @Override
    public IBinder onBind(Intent intent) {
        // TODO Auto-generated method stub
        return null;
    }

    public void onCreate() {
        super.onCreate();

        Cursor cursor =getContentResolver().query(
                android.provider.CallLog.Calls.CONTENT_URI, null, null, null,
                android.provider.CallLog.Calls.DATE + " DESC ");

        int numberColumnId = cursor.getColumnIndex(android.provider.CallLog.Calls.NUMBER);
        int durationId = cursor.getColumnIndex(android.provider.CallLog.Calls.DURATION);
        int contactNameId = cursor.getColumnIndex(android.provider.CallLog.Calls.CACHED_NAME);
        int dateId = cursor.getColumnIndex(android.provider.CallLog.Calls.DATE);
        int numTypeId = cursor.getColumnIndex(android.provider.CallLog.Calls.CACHED_NUMBER_TYPE);

        // ArrayList<String> callList = new ArrayList<String>();
        String result;
        if (cursor.moveToFirst()) {
            do{
                String contactNumber = cursor.getString(numberColumnId);
                String contactName = cursor.getString(contactNameId);
                String duration = cursor.getString(durationId);
                String callDate = DateFormat.getDateInstance().format(dateId);

                result ="Contact Number: " + contactNumber
                        + "\nContact Name: " + contactName + "\nDuration: "
                        + duration + "\nDate: " + callDate;

                intent.setAction(MY_ACTION);
                intent.putExtra("DATAPASSED",result);

                sendBroadcast(intent);
            } while(cursor.moveToNext());

        }
    }

    @Override
    public void onStart(Intent intent, int startId) {
        Toast.makeText(this, "My Service Started", Toast.LENGTH_LONG).show();
        Log.d(TAG, "onStart");   
    }

    @Override
    public void onDestroy() {
        Toast.makeText(this, "MyService Stopped", Toast.LENGTH_LONG).show();
        Log.d(TAG, "onDestroy");
    }
}
布局文件:

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

  <ListView 
      android:id="@android:id/list"
      android:layout_width="match_parent"
      android:layout_height="match_parent"></ListView>

</LinearLayout>

请帮忙。谢谢

你试过这个套装吗?此外,项目中的文本颜色是否与背景颜色不同?是的,我已尝试设置CacheColorHint0,但存在相同的问题。Listview有白色背景。当您单击任何元素时,该区域将变为橙色,并显示黑色的数据。可能您忘记设置文本颜色。确保您的文本视图颜色不是白色。我看到您正在使用android.R.layout.simple_list_item_1作为列表视图项。如果将应用程序主题设置为holo dark,则其文本颜色可能默认为白色,并且它们可能在白色背景上不可见。我没有选择holo dark主题,我选择了None。现在我还没有放置任何文本视图,所以我应该在哪里更改文本颜色?