I created a function in a fragment. And I want to call this function when I click the button that is in the user adapter, but I can not call the fragment function from the user adapter.
My code for the adapter is to click on the button and call the snippet function
viewHolder.accept.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
removeListItem(viewHolder.order_card_layout, position);
android.support.v4.app.Fragment newFragment = new NewPageActivity();
android.support.v4.app.FragmentTransaction ft = ((FragmentActivity)mContext).getSupportFragmentManager().beginTransaction();
ft.sendorder(data.getorder_id());
ft.add(R.id.framelay, newFragment).commit();
}
});
My function, which is in the fragment
public class NewPageActivity extends Fragment{
public void SendOrder( String OrderId)
{
final String serverid = sp.getString("serverid", "null");
Log.e("TAG", "SendOrder: "+serverid +OrderId );
new SendOrder().execute(new Config().addNewOrder, serverid, OrderId);
}
}
source
share