CheckedTextView实现ListView的单选效果

CheckedTextView实现ListView的单选效果

CheckedTextView实现ListView的单选效果_第1张图片


1.activity_main.xml代码如下:


2.item.xml代码如下



3.MainActivity.java代码如下

package com.example.checktextview;

import android.os.Bundle;
import android.app.Activity;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends Activity {
	
	private ListView listView;

	private String[] data = {"android","ios","java"};
	
	private void setupView(){
		listView = (ListView) findViewById(R.id.listView);
		
		ArrayAdapter adapter = new ArrayAdapter(this, R.layout.item, data);
		
		listView.setAdapter(adapter);
	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		setupView();
	}

}



你可能感兴趣的:(Android_UI)