У меня есть список с кнопкой в нем. есть ли какой-либо возможный способ проверить, какая кнопка была нажата и в какой позиции списка?Android Listview с кнопкой get Позиция позиция
вот мой код.
final RelativeLayout layoutFooter2 = (RelativeLayout) getLayoutInflater().inflate(R.layout.foodlist, null);
final Button btnBack = (Button) layoutFooter2.findViewById(R.id.Back);
// buttonadd
final Button btnadd = (Button) layoutFooter2.findViewById(R.id.btnaddd);
// buttondelete
final ListView listView = getListView();
final TextView txvSum = (TextView) layoutFooter.findViewById(R.id.Sum);
txvSum.setText("");
listView.invalidateViews();
listView.setTextFilterEnabled(true);
listView.addFooterView(layoutFooter);
listView.setAdapter(getListAdapter());
// changes have been done here in order to fit the buttons in textview55+ changes to large/foodlist.
setListAdapter(new ArrayAdapter<Object>(this, R.layout.foodlist, R.id.textview55, ListItemSalads));
getWindow().getDecorView().setBackgroundColor(Color.BLACK);
btnadd.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
Toast.makeText(ActivityFoodsSalads.this, "Button Clicked", Toast.LENGTH_SHORT).show();
}
});
XML файл
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/kati"
>
<TextView
android:id="@+id/textview55"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/listviewborder"
android:textColor="#FFFFFF"
android:padding="12dp"
android:textSize="24sp" >
</TextView>
<Button
android:id="@+id/btnaddd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="112dp"
android:alpha="1"
android:background="#3b3974"
android:focusable="false"
android:focusableInTouchMode="false"
android:minWidth="90dp"
android:text="+"
android:textColor="#f1ecef" />
Любой совет много appriciated.Cheers.
один совет поставить код, что у попытался – Pavan
Добавьте свой код адаптера и элемент ListView/строки XML на ваш вопрос – petey
ОК я буду делать это сейчас спасибо, ребята. – Kristo