Wednesday, 3 July 2013

listallclick

public class Recipelist extends Activity implements OnItemClickListener{

list.setOnItemClickListener(Recipelist.this);

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
System.out.println("pos clicked in recipe details===="+arg2);
Intent i=new Intent(Recipelist.this,Ingredient.class);
Bundle success=new Bundle();
success.putString("RECID",recId[arg2]);
success.putString("CATID",catId);
success.putString("RECTITLE",recTitle[arg2]);
success.putString("CATTITLE",catTitle);
i.putExtras(success);
startActivity(i);
}

public void goback(View v)
{

Intent i=new Intent(Recipelist.this,Rezepte.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
finish();
}

public static class Utility {
public static void setListViewHeightBasedOnChildren(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
if (listAdapter == null) {
// pre-condition
return;
}

int totalHeight = 0;
int desiredWidth = MeasureSpec.makeMeasureSpec(listView.getWidth(), MeasureSpec.AT_MOST);
for (int i = 0; i < listAdapter.getCount(); i++) {
View listItem = listAdapter.getView(i, null, listView);
listItem.measure(desiredWidth, MeasureSpec.UNSPECIFIED);
totalHeight += listItem.getMeasuredHeight();
}

ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
listView.setLayoutParams(params);
listView.requestLayout();
}
}
public void onBackPressed(){

Intent i=new Intent(Recipelist.this,Rezepte.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
finish();
}


No comments:

Post a Comment