I have a ListView, and an adapter item layout that follows the basic image of it
ProblemisthatwhenIclickonanyareaoftheiteminthelist,everycomponentis"selected"
IwouldliketohavetheeffectofAction1,Action2andDescriptionseparated.
Forexample:
XMLLayout:
...<LinearLayoutandroid:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/linearLayout"
android:layout_marginLeft="3dp">
<!--descrição-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:id="@+id/txtDescricao"
android:text="Descricao" />
<!--este é o "separador" horizontal-->
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100"
android:orientation="horizontal">
<!--Tentei colocar um Linear Layout "fora" e marcar clickable = true -->
<LinearLayout android:layout_width="wrap_content"
android:layout_weight="50"
android:clickable="true"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/txtAcao1"
android:text="Acao 1" />
</LinearLayout>
<!--este é o "separador" vertical entre ação 1 e ação 2-->
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@android:color/darker_gray" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="center"
android:id="@+id/txtAcao2"
android:text="Acao 2" />
</LinearLayout>
</LinearLayout>
I also tried to add a setOnClickListener
in Action1 and Action2, but it did not work
Follow the .java class
//ViewHolder
static class ViewHolderItem {
public TextView txtAcao1;
public TextView txtAcao2;
public View txtDescricao;
}
//Adapter
class RoteiroAdapter extends BaseAdapter{
private Context mContext = null;
private List<ItemRoteiro> mListaRoteiro = null;
public RoteiroAdapter(Context context, List<ItemRoteiro> lista){
this.mContext = context;
this.mListaRoteiro = lista;
}
@Override
public int getCount() {
return mListaRoteiro.size();
}
@Override
public Object getItem(int position) {
return mListaRoteiro.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolderItem viewHolder;
if(convertView == null){
LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
convertView = inflater.inflate(R.layout.item_roteiro, parent, false);
viewHolder = new ViewHolderItem();
viewHolder.txtAcao1= (TextView) convertView.findViewById(R.id.txtAcao1);
viewHolder.txtAcao2= (TextView) convertView.findViewById(R.id.txtAcao2);
convertView.setTag(viewHolder);
}
else{
viewHolder = (ViewHolderItem) convertView.getTag();
}
ItemRoteiro item = mListaRoteiro.get(position);
if(item != null) {
viewHolder.txtAcao1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
return convertView;
}
}
Does anyone know how to get this effect ??
Thank you !!