Skip to content

Instantly share code, notes, and snippets.

@codeforfun-jp
Created August 3, 2022 00:43
Show Gist options
  • Save codeforfun-jp/f504bb42494e33c23e6c653202b61ee8 to your computer and use it in GitHub Desktop.
Save codeforfun-jp/f504bb42494e33c23e6c653202b61ee8 to your computer and use it in GitHub Desktop.
【Java】ListView with searchview 2
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// データを用意
String[] data = {
"あだち", "いのうえ", "うえき", "うえだ", "うえと", "うちだ",
"うちの", "うつみ", "うの", "えとう", "おおた"
};
// ListViewにデータをセットする
ListView list = findViewById(R.id.list);
list.setAdapter(new ArrayAdapter<>(
this,
android.R.layout.simple_list_item_1,
data
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment