0

I have the following code:

String[] citazioni = getResources().getStringArray(R.array.citazioni);
List<String> CitazioniOutput = new ArrayList<String>();
for (String value : citazioni) {
    CitazioniOutput.add(value+"\n<Button android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:text=\"@string/share\" android:onClick=\"Condividi("+value+")\" />");
}

ArrayAdapter<String> adapter= new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,CitazioniOutput);

ListView listView= (ListView)findViewById(R.id.ListViewCitazioni);
listView.setAdapter(adapter);

I added the text "<Button android:layout ..." to each CitazioniOutput item. I would like to convert this text into an actual Button.

@Raghunandan: yes, I would like to add the share button for every item :)

2 Answers2

1

You can't translate text values into new views))

If you want to add button into each row, please use custom view: Custom Adapter for List View

Community
  • 1
  • 1
Dimmerg
  • 2,113
  • 1
  • 13
  • 14
1

You may need to create a custom listview with custom adapter. Use a custom layout for listview item. Add a button in custom layout file. There are plenty of tutorials in web how to do this. Check these links

Custom Listview - Android Hive

Listview - Vogella.com

Ahamed Ishak
  • 972
  • 11
  • 16