一維陣列顯示在listview,利用ArrayAdapter
package com.jbuduoo.test001;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
public class MainActivity extends AppCompatActivity {
ArrayAdapter<String> adapter;
ListView lv;
String[] A={"1","2","3","4","5"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lv =findViewById(R.id.lv);
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1,A);
lv.setAdapter(adapter);
}
}
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
public class MainActivity extends AppCompatActivity {
ArrayAdapter<String> adapter;
ListView lv;
String[] A={"1","2","3","4","5"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lv =findViewById(R.id.lv);
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1,A);
lv.setAdapter(adapter);
}
}
留言
張貼留言