2
I am making an application and at the end of the data inserts the user will view a summary with a listView
. So far so good, but I want to create, right down after the listview
, a finish button, but I can’t put it, if I put it inside the XML, it inserts the button inside all the items. How do I do this?
My XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:id="@+id/tema"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textColor="#000000"
/>
<TextView
android:id="@+id/palavras"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textColor="#000000"
/>
</LinearLayout>
My code:
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String [] tema = new String[] {"Tema1", "Tema2", "Tema3"};
String [] tempo = new String[] {"1:20", "2:32", "1:10"};
String [] palavras = new String[] {"Palavras, curió, celular, computador","Camisa, mochila, Sara, SBC","Tunts, Tunts, Quero, ver"};
ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String,String>>();
for(int i=0; i<3; i++ ) {
HashMap<String,String> item = new HashMap<String,String>();
item.put("tema", tema[i]+": "+tempo[i]);
item.put("palavras", palavras[i]);
list.add(item);
}
// Simpler Adapter
String[] from = new String[] {"tema","palavras"};
int[] to = new int[] {R.id.tema, R.id.palavras};
setListAdapter(new SimpleAdapter(this,list,R.layout.activity_main,from,to));
}
You would have been able to display your XML?
– Felipe Avelar
Your problem is with your
LinearLayout
orRelativeLayout
you are using to maintain theListView
, probably the propertyOrientation
its layout is incorrect...– Paulo Roberto Rosa
I added the code. How can I put the button there, because if I add it in xml, it creates a button for each pair of items.
– João Neto
That one
XML
that you passed is theListView
, just do what the answer proposes and insert the button at the end of theXML
who is theListView
.– Felipe Avelar