如何更改listview的文本?

时间:2018-03-15 05:13:56

标签: java android listview text

我正在创建一个音板应用,我使用ListView来表达声音。我想更改名称,因为它现在使用文件夹名称。我也是新人,我不懂英语。请帮帮我。

这是我从raw获取声音的代码:

MediaPlayer mp; 
Uri uri; 
ListView listView; 
TextView textBilgi; 

@Override 
protected void onCreate(Bundle savedInstanceState) {  super.onCreate(savedInstanceState); setContentView(R.layout.activity_giris); 
    Field[] fields = R.raw.class.getFields(); 
    String[] mediaList = new String[fields.length]; 
    for (int count = 0; count < fields.length; count++) mediaList[count] =  fields[count].getName(); 
    textBilgi = (TextView) findViewById(R.id.textBilgi1); 
    listView = (ListView) findViewById(R.id.listview); 
    ArrayAdapter<String > adapter = new ArrayAdapter<String>(giris.this, android.R.layout.simple_list_item_1, mediaList); listView.setAdapter(adapter); 
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 
    String uri = "android.resource://" + getPackageName() + "/raw/" + ((TextView) view).getText(); 
    if (mp != null && mp.isPlaying()) mp.stop(); 
    mp = MediaPlayer.create(getApplicationContext(), Uri.parse(uri)); mp.start(); textBilgi.setText(((TextView) view).getText() + " [" + mp.getDuration() / 1000 + " sn.]"); } 
    });

我搜索了它,据我所知,我需要第二个ListView。还有其他办法吗?

0 个答案:

没有答案