0
I have a model_list_view.xml like this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/lnImprimir"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.3"
android:orientation="horizontal">
<Button
android:id="@+id/buttonSimNaoCozinha"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:textSize="1sp"
android:textColor="#ffffff"
android:background="@drawable/lista_anotacoes"
android:typeface="sans"/>
</LinearLayout>
<LinearLayout
android:id="@+id/lnQuantidade"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewQuantidade"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_weight="1"
android:gravity="left|center_vertical"
android:text="TextView"
android:textColor="#000000"
android:textSize="25sp"
android:typeface="sans" />
</LinearLayout>
<LinearLayout
android:id="@+id/lnDescricao"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.80"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewDescricao"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="TextView"
android:textColor="#000000"
android:textSize="20sp"
android:typeface="sans" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewValor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right|center_vertical"
android:text="TextView"
android:textColor="#000000"
android:textSize="25sp"
android:typeface="sans" />
</LinearLayout>
Where the buttonSimNaoCho I want to appear only when it is YES inside the Listview I made like this
private void criarListagem() {
/**
* Busca os dados do seu método
*/
db.buscarDadosComanda(objComanda); /// Metodo de busca
/**
* Passa os valores
*/
String[] from = {
"imprimir",
"quantidade",
"descricao",
"valor"}; // nome dos campos da tabela
int[] to = {
R.id.buttonSimNaoCozinha,
R.id.textViewQuantidade,
R.id.textViewDescricao,
R.id.textViewValor}; // Nome dos campos do model_listview
// if (objComanda.getImprimir().equals("NOT")) { // btnAnotacoes.setVisibility(View.INVISIBLE); // } Else { // btnAnotacoes.setVisibility(View.VISIBLE); // }
//noinspection deprecation
ad = new SimpleCursorAdapter(getApplicationContext(), R.layout.model_listview_comanda, db.cursorListagem, from, to);
/**
* habilita o click no item da lista
*/
listview.setOnItemClickListener(TelaComandaActivity.this);
listview.setAdapter(ad);
}
Also if possible I would like to know which command I have to use for onClick on this button inside Listview.