Boa noite,
Estou desenvolvendo um aplicativo para android, e tenho na minha tela principal um ListView e uma Activity com dois ImageView e um TextView, essa essa Activity é chamada na classe principal que controla do ListView, até aí tudo certo.
O que eu gostaria de saber se é possível fazer com que um dos ImageView quando clicado (já que pertence ao ListView), pegasse o id do ListView na sua ação de onClick.
Alguém sabe se isso é possivel?
Segue os códigos:
Tela principal onde tem o ListView
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MyActivity"
>
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="@+id/listViewPlacas"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|top"
android:divider="#FFFFFF"
android:dividerHeight="4dp"
android:layout_weight="1"
android:listSelector="@drawable/list_selector"
android:background="@drawable/fundo_list"
/>
</FrameLayout>
<!-- android:layout_gravity="start" tells DrawerLayout to treat
this as a sliding drawer on the left side for left-to-right
languages and on the right side for right-to-left languages.
If you're not building against API 17 or higher, use
android:layout_gravity="left" instead. -->
<!-- The drawer is given a fixed width in dp and extends the full height of
the container. -->
<fragment android:id="@+id/navigation_drawer"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:name="checklist.system.cooper.br.syschecklist.NavigationDrawerFragment"
tools:layout="@layout/fragment_navigation_drawer" />
Tela onde tem os itens do ListView
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<View
android:id="@+id/Vbarra"
android:layout_height="2dp"
android:layout_width="335dp"
android:background="#3929769f"
android:visibility="gone" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/imagemview"
android:layout_width="64dp"
android:layout_height="47dp"
android:src="@drawable/checklist"
android:layout_gravity="top" />
<TextView
android:layout_width="wrap_content"
android:layout_height="38dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/txtPlacaPrincipal"
android:layout_weight="0.40"
android:textColor="#ff000000"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="46dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="0"
android:id="@+id/txtQuantidade"
android:layout_weight="0.22"
android:textColor="#ff000000"
android:textStyle="bold" />
<ImageView
android:id="@+id/imagemAdd"
android:layout_width="64dp"
android:layout_height="47dp"
android:src="@drawable/ic_action_add_to_queue"
android:layout_gravity="top"
android:onClick="addCheckList"/>
</LinearLayout>
Código da chamada do ImageView
public void addCheckList(View v)
{
}
Obrigado
ListView