I have check box,with edit_texts of child expandable list_view in parent layout. then my doubt is after entering the mobile number in edit_text field , then if i want remove check box ,mobile number edit text field automatically cleared, how to avoid this issue? please give me any solution.
this is screen_shot of entering mobile in edit_text field
this is screen_shot of Un_click Check_box then mobile number cleared,how to avoid this issue?
this is payment activity
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
InputMethodManager im = (InputMethodManager) getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
im.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
if(isChecked){
//doChange(mobileNumber);
total_amount = Integer.parseInt(strAmount);
int k = (total_amount * 10/100); //10% amount.
if(str_cash == null){
checkBox.setChecked(false);
bargaincry_Cash.setText("0");
textView.setText(DbUtils.get(Payment_Activity.this).getTotalOfColumns(List_Deal_Data.class, "discountedPrice", null) + "");
Toast.makeText(Payment_Activity.this,"please update your bargaincrycash",Toast.LENGTH_SHORT).show();
}else{
bcash = Integer.parseInt(str_cash);
if (k > Integer.parseInt(str_cash)) {
checkBox.setChecked(false);
//bargaincry_Cash.setText("0");
textView.setText(DbUtils.get(Payment_Activity.this).getTotalOfColumns(List_Deal_Data.class, "discountedPrice", null) + "");
Toast.makeText(Payment_Activity.this, "your bargaincrycash is lessthan to discount price", Toast.LENGTH_SHORT).show();
} else {
real_amount = total_amount - k; // after percentage then get the real amount from total_amount subtrack with k.
strCash_realamount = bcash - k;
textView.setText(String.valueOf(real_amount));
bargaincry_Cash.setText(String.valueOf(strCash_realamount));
expandablePayListAdapter.UpdateMyText(textView.getText().toString());
totalAmount.setText("(you can only use max."+real_amount+" UGX Bargaincry Cash in this transaction.)");
}
}
}else {
bargaincry_Cash.setText(str_cash);
expandablePayListAdapter.UpdateMyText(strAmount);
textView.setText(strAmount);
//editor.putString("c_amount",strAmount);
expandablePayListAdapter.notifyDataSetChanged();
totalAmount.setText("(you can only use max."+strAmount+" UGX Bargaincry Cash in this transaction.)");
InputMethodManager inputManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),InputMethodManager.HIDE_NOT_ALWAYS);
//Toast.makeText(Payment_Activity.this,"un_checked "+ total_amount,Toast.LENGTH_SHORT).show();
//doChange(mobileNumber);
}
expandablePayListAdapter.notifyDataSetChanged();
}
});
this is payment activity layout
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:id="@+id/linearLayout"
android:gravity="center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Total Amount :"
android:textColor="#9e1828"
android:id="@+id/totalAmount"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="UGX"
android:layout_marginLeft="2dp"
android:textColor="#df001a"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="30"
android:textColor="#df001a"
android:layout_marginLeft="2dp"
android:id="@+id/price_total"
android:gravity="center_horizontal"
android:layout_toRightOf="@+id/totalAmount"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/text_LinearL"
android:layout_marginTop="5dp"
android:gravity="center_horizontal"
android:layout_below="@+id/linearLayout"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your Bargaincry Cash Balance:"
android:textColor="#123"
android:layout_marginLeft="2dp"
android:textSize="15dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:id="@+id/bargainCryCash"
android:textColor="@color/colorPrimary"
android:text="0"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:text="UGX"
android:textColor="@color/colorPrimary"/>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/check_ll"
android:scrollbars="none"
android:gravity="center_horizontal"
android:layout_below="@+id/text_LinearL">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/check_box"
android:scrollbars="none"
android:text="Use by BargainCry Cash"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/check_ll"
android:id="@+id/textLL"
android:gravity="center_horizontal"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:id="@+id/pricetotal" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="25dp"
android:scrollbars="none"
android:background="@color/White"
android:layout_below="@+id/textLL">
<ExpandableListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:scrollbars="none"
android:id="@+id/payment_list"/>
</LinearLayout>
</RelativeLayout>
this is expandablepay_listadapter
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final ProgressBar progressBar = (ProgressBar)finalConvertView.findViewById(R.id.button_pbar);
airtel_number = (EditText) finalConvertView.findViewById(R.id.enterMobile);
mobileNum = airtel_number.getText().toString();
if (TextUtils.isEmpty(mobileNum)) {
Toast.makeText(_context, "please enter mobile number", Toast.LENGTH_SHORT).show();
} else {
Intent intent = ((Activity) _context).getIntent();
String deal_IDs = intent.getStringExtra("dealIds");
final String user_id = intent.getStringExtra("user_id");
int order_Id = intent.getIntExtra("orderId",0);
RequestParams params = new RequestParams();
params.put("airtel_number", mobileNum);
params.put("dealIDS", deal_IDs);
params.put("userID", user_id);
params.put("amount", mystr_amount);
params.put("payment_type", "1");
params.put("orderId", order_Id);
params.put("bargaincry_cash","yes");
Toast.makeText(_context, "\ndealsss "+deal_IDs
+"\n amnt"+mystr_amount
+"\n dealid's "+deal_IDs
+"\n orderid "+order_Id
+"\n mobileNum "+mobileNum
+"\n m_num "+mobileNum,Toast.LENGTH_SHORT).show();
progressBar.setVisibility(View.VISIBLE);
finalButton1.setVisibility(View.GONE);
RestClient.get(_context).diskCacheEnable(true).new NetworkTask<Void, SendManualPayment_Response>(SendManualPayment_Response.class, Http.FORM_DATA) {
@Override
protected void onPostExecute(SendManualPayment_Response sendManualPayment_response) {
super.onPostExecute(sendManualPayment_response);
progressBar.setVisibility(View.GONE);
finalButton1.setVisibility(View.VISIBLE);
if (sendManualPayment_response != null && sendManualPayment_response.status != null && sendManualPayment_response.status.contains("done")) {
if(sendManualPayment_response.getManualPayment().getUserID() != null){
String user_ID = sendManualPayment_response.getManualPayment().getUserID();
amount_ = sendManualPayment_response.getManualPayment().getAmount();
String order_ID = sendManualPayment_response.getManualPayment().getOrder_id();
deal_ID = sendManualPayment_response.getManualPayment().getDealIDS();
}
DisplayDialog();
} else {
failedDialog();
}
}
}.execute("http://ift.tt/2vkQdwe", params.toString());
}
}
});
this is expandablepay_listadapter layout
<TabHost
android:id="@+id/tabHost_airtelPayemtn"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:background="@drawable/paylist_group_shape"
android:layout_height="wrap_content"></TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:scrollbars="none"
android:layout_height="match_parent">
<!--android:background="#ffc916"-->
<LinearLayout
android:id="@+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tab_one"
android:textColor="#2f50e1"
android:text="This is tab 1" />
</LinearLayout>
<!--android:background="#da8200"-->
<LinearLayout
android:id="@+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tab_two"
android:textColor="#2f50e1"
android:text="This is tab 2" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
<RelativeLayout
android:layout_width="match_parent"
android:layout_below="@id/tabHost_airtelPayemtn"
android:id="@+id/mobile_ll"
android:focusable="false"
android:inputType="phone"
android:scrollbars="none"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true">
<EditText
android:id="@+id/enterMobile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Mobile Number"
android:inputType="phone"
android:imeOptions="actionPrevious"
android:singleLine="true"
android:ems="10"
android:maxLength="10"
android:maxLines="1"/>
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/airtel_amount_ll"
android:scrollbars="none"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:layout_below="@+id/mobile_ll">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="textAutoComplete"
android:focusableInTouchMode="false"
android:focusable="false"
android:hint="amount"
android:scrollbars="none"
android:nextFocusUp="@+id/airtel_amount"
android:layout_below="@+id/mobile_ll"
android:nextFocusLeft="@+id/airtel_amount"
android:windowSoftInputMode="stateUnchanged"
android:id="@+id/airtel_amount" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:gravity="center"
android:layout_below="@+id/airtel_amount_ll"
android:orientation="horizontal">
<ProgressBar
android:id="@+id/button_pbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foregroundGravity="center_horizontal"
android:layout_centerInParent="true"
android:visibility="gone" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/amount"
android:text="Pay Now"
android:background="@drawable/login_button_selector"
android:textColor="#ffffff"
style="@style/AppTheme"
android:id="@+id/payNow" />
</LinearLayout>
Aucun commentaire:
Enregistrer un commentaire