I am able to Display Hint to the Spinner through the layout.I want to achieve the spinner field to be clear after the click in Submit button and should display hint. I am using spinner_district.setSelection(1); it is displaying the array of value 1 but i want to display hint not any value of spinner.
for clearing field
registerSchoolName.setText("");
registerSchoolAddress.setText("");
registerSchoolPhone.setText("");
registerSchoolEmail.setText("");
registerSchoolWebsite.setText("");
registerSchoolFee.setText("");
registerSchoolFee1.setText("");
registerSchoolFee2.setText("");
registerSchoolFee3.setText("");
registerSchoolFee3.setText("");
registerSchoolFee4.setText("");
registerSchoolFee5.setText("");
registerSchoolFee6.setText("");
registerSchoolFee7.setText("");
registerSchoolFee8.setText("");
registerSchoolFee9.setText("");
schoolEstDate.setText("");
schoolAdmissionStartDate.setText("");
schoolAdmissionEndDate.setText("");
// spinner_district.setAdapter(null);
spinner_district.setPrompt("District");
// spinner_district.setSelection(1);
function
public void onClick(View v) {
switch (v.getId()) {
case R.id.send_school_registration_form:
if (isConnected()) {
String name = registerSchoolName.getText().toString();
String address = registerSchoolAddress.getText().toString();
String phone = registerSchoolPhone.getText().toString();
String email = registerSchoolEmail.getText().toString().trim();
String emailPattern = "[a-zA-Z0-9._-]+#[a-z]+\\.+[a-z]+";
String website = registerSchoolWebsite.getText().toString();
String estbdate = schoolEstDate.getText().toString();
String admissionOpen = schoolAdmissionStartDate.getText().toString();
String admissionEnd = schoolAdmissionEndDate.getText().toString();
district = null;
if (spinner_district != null && spinner_district.getSelectedItem() != null) {
district = (String) spinner_district.getSelectedItem();
}
country = null;
if (spinner_country != null && spinner_country.getSelectedItem() != null) {
country = (String) spinner_country.getSelectedItem();
}
institution = null;
if (spinner_institution != null && spinner_institution.getSelectedItem() != null) {
institution = (String) spinner_institution.getSelectedItem();
}
fee = registerSchoolFee.getText().toString();
level = null;
if (spinner_school_level != null && spinner_school_level.getSelectedItem() != null) {
level = (String) spinner_school_level.getSelectedItem();
}
if (addSchoolProgram1.getVisibility() == View.VISIBLE) {
fee1 = registerSchoolFee1.getText().toString();
level1 = null;
if (spinner_school_level1 != null && spinner_school_level1.getSelectedItem() != null) {
level1 = (String) spinner_school_level1.getSelectedItem();
}
}
if (addSchoolProgram2.getVisibility() == View.VISIBLE) {
fee2 = registerSchoolFee2.getText().toString();
level2 = null;
if (spinner_school_level2 != null && spinner_school_level2.getSelectedItem() != null) {
level2 = (String) spinner_school_level2.getSelectedItem();
}
}
if (addSchoolProgram3.getVisibility() == View.VISIBLE) {
fee3 = registerSchoolFee3.getText().toString();
level3 = null;
if (spinner_school_level3 != null && spinner_school_level3.getSelectedItem() != null) {
level3 = (String) spinner_school_level3.getSelectedItem();
}
}
if (addSchoolProgram4.getVisibility() == View.VISIBLE) {
fee4 = registerSchoolFee4.getText().toString();
level4 = null;
if (spinner_school_level4 != null && spinner_school_level4.getSelectedItem() != null) {
level4 = (String) spinner_school_level4.getSelectedItem();
}
}
if (addSchoolProgram5.getVisibility() == View.VISIBLE) {
fee5 = registerSchoolFee5.getText().toString();
level5 = null;
if (spinner_school_level5 != null && spinner_school_level5.getSelectedItem() != null) {
level5 = (String) spinner_school_level5.getSelectedItem();
}
}
if (addSchoolProgram6.getVisibility() == View.VISIBLE) {
fee6 = registerSchoolFee6.getText().toString();
level6 = null;
if (spinner_school_level6 != null && spinner_school_level6.getSelectedItem() != null) {
level6 = (String) spinner_school_level6.getSelectedItem();
}
}
if (addSchoolProgram7.getVisibility() == View.VISIBLE) {
fee7 = registerSchoolFee7.getText().toString();
level7 = null;
if (spinner_school_level7 != null && spinner_school_level7.getSelectedItem() != null) {
level7 = (String) spinner_school_level7.getSelectedItem();
}
}
if (addSchoolProgram8.getVisibility() == View.VISIBLE) {
fee8 = registerSchoolFee8.getText().toString();
level8 = null;
if (spinner_school_level8 != null && spinner_school_level8.getSelectedItem() != null) {
level8 = (String) spinner_school_level8.getSelectedItem();
}
}
if (addSchoolProgram9.getVisibility() == View.VISIBLE) {
fee9 = registerSchoolFee9.getText().toString();
level9 = null;
if (spinner_school_level9 != null && spinner_school_level9.getSelectedItem() != null) {
level9 = (String) spinner_school_level9.getSelectedItem();
}
}
if ((name.matches("")) || (address.matches("")) || (phone.matches("")) || (email.matches("")) || (website.matches("")) || (estbdate.matches("")) || (admissionOpen.matches(""))
|| (admissionEnd.matches("")) || (district.matches("")) || (country.matches("")) || (institution.matches("")) || (fee.matches("")) || (level.matches("")) ||
(schoolLogoUpload.getDrawable() == null)
) {
Toast.makeText(this, "Please fill up all the fields", Toast.LENGTH_LONG).show();
} else {
if ((email.matches(emailPattern)) && ((Patterns.WEB_URL.matcher(website)).matches())) {
Bitmap image = ((BitmapDrawable) schoolLogoUpload.getDrawable()).getBitmap();
new UploadImage(image, name, address, phone, email, website, district, country, institution, estbdate, fee, level, fee1, level1, fee2, level2, fee3, level3, fee4, level4, fee5, level5, fee6, level6, fee7, level7,
fee8, level8, fee9, level9, admissionOpen,
admissionEnd).execute();
} else
Toast.makeText(getApplicationContext(), "Invalid website and email address", Toast.LENGTH_LONG).show();
}
registerSchoolName.setText("");
registerSchoolAddress.setText("");
registerSchoolPhone.setText("");
registerSchoolEmail.setText("");
registerSchoolWebsite.setText("");
registerSchoolFee.setText("");
registerSchoolFee1.setText("");
registerSchoolFee2.setText("");
registerSchoolFee3.setText("");
registerSchoolFee3.setText("");
registerSchoolFee4.setText("");
registerSchoolFee5.setText("");
registerSchoolFee6.setText("");
registerSchoolFee7.setText("");
registerSchoolFee8.setText("");
registerSchoolFee9.setText("");
schoolEstDate.setText("");
schoolAdmissionStartDate.setText("");
schoolAdmissionEndDate.setText("");
// spinner_district.setAdapter(null);
spinner_district.setPrompt("District");
// spinner_district.setSelection(1);
//spinner_district.setSelection(1);
Spinner spinner_country, spinner_institution, spinner_school_level, spinner_school_level1, spinner_school_level2, spinner_school_level3, spinner_school_level4,
spinner_school_level5, spinner_school_level6, spinner_school_level7, spinner_school_level8, spinner_school_level9;
} else {
Toast.makeText(this, "Please check your internet connection", Toast.LENGTH_LONG).show();
}
break;
case R.id.cancel_school_registration_form:
this.finish();
break;
case R.id.register_school_logo:
Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(galleryIntent, RESULT_LOAD_IMAGE);
break;
case R.id.register_school_estdate:
datePickerDialogSchool.show();
break;
case R.id.school_admission_startDate:
schoolAdmissionStartDatePicker.show();
break;
case R.id.school_admission_end_date:
schoolAdmissionEndDatePicker.show();
break;
case R.id.add_more_school_programs:
if (addMoreSchoolProgram.getVisibility() == View.VISIBLE) {
if (addSchoolProgram9.getVisibility() == View.GONE) {
if (addSchoolProgram8.getVisibility() == View.GONE) {
if (addSchoolProgram7.getVisibility() == View.GONE) {
if (addSchoolProgram6.getVisibility() == View.GONE) {
if (addSchoolProgram5.getVisibility() == View.GONE) {
if (addSchoolProgram4.getVisibility() == View.GONE) {
if (addSchoolProgram3.getVisibility() == View.GONE) {
if (addSchoolProgram2.getVisibility() == View.GONE) {
if (addSchoolProgram1.getVisibility() == View.GONE) {
addSchoolProgram1.setVisibility(View.VISIBLE);
} else
addSchoolProgram2.setVisibility(View.VISIBLE);
} else
addSchoolProgram3.setVisibility(View.VISIBLE);
} else
addSchoolProgram4.setVisibility(View.VISIBLE);
} else
addSchoolProgram5.setVisibility(View.VISIBLE);
} else
addSchoolProgram6.setVisibility(View.VISIBLE);
} else
addSchoolProgram7.setVisibility(View.VISIBLE);
} else
addSchoolProgram8.setVisibility(View.VISIBLE);
} else
addSchoolProgram9.setVisibility(View.VISIBLE);
} else
addMoreSchoolProgram.setVisibility(View.GONE);
}
break;
case R.id.register_school_email:
}
}
How can resetting to spinner be done with providing hint not the
spinner values??
you can use following code to solve the issue
admissionEnd).execute();
registerSchoolName.setText("");
registerSchoolAddress.setText("");
registerSchoolPhone.setText("");
registerSchoolEmail.setText("");
registerSchoolWebsite.setText("");
registerSchoolFee.setText("");
registerSchoolFee1.setText("");
registerSchoolFee2.setText("");
registerSchoolFee3.setText("");
registerSchoolFee3.setText("");
registerSchoolFee4.setText("");
registerSchoolFee5.setText("");
registerSchoolFee6.setText("");
registerSchoolFee7.setText("");
registerSchoolFee8.setText("");
registerSchoolFee9.setText("");
schoolEstDate.setText("");
schoolAdmissionStartDate.setText("");
schoolAdmissionEndDate.setText("");
// spinner_district.setAdapter(null);
spinner_district.setPrompt("District");
spinner_district.setSelection(0);
use setPrompt and setSelection
Related
I used accessibility service to get all texts on screen. After minutes working normally, it caused ANR with some GC allocated... logs and few seconds after, it crashed with this error:
#Override
public void onAccessibilityEvent(final AccessibilityEvent event) {
try {
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
if (powerManager == null || !powerManager.isInteractive()) {
return;
}
if (FirebaseAuth.getInstance().getCurrentUser() == null) return;
CharSequence eventPackageName = event.getPackageName();
if (eventPackageName != null) {
if (eventPackageName.equals(BuildConfig.APPLICATION_ID)) return;
if (eventPackageName.equals(getCurrentKeyboardPackageName())) return;
int eventType = event.getEventType();
if (eventType == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED || eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
AccessibilityNodeInfo mNodeInfo = event.getSource();
StringBuilder stringBuilder = new StringBuilder("");
getAllTextViews(mNodeInfo, stringBuilder);
String value = stringBuilder.toString().replace('\n', ' ').replaceAll(" +", " ");
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
My getAllTextViews() method:
private void getAllTextViews(AccessibilityNodeInfo nodeInfo, StringBuilder stringBuilder) {
if (nodeInfo == null) return;
if (!TextUtils.isEmpty(nodeInfo.getText())) {
stringBuilder.append(" " + nodeInfo.getText());
}
for (int i = 0; i < nodeInfo.getChildCount(); i++) {
getAllTextViews(nodeInfo.getChild(i), stringBuilder);
}
}
Any help will be appreciated. Thank a lot!
What you need is to use recycle() method of AccessibilityNodeInfo after info is used.
I have implemented recycler view in the following manner :
now on the click of any one of the rows, the view is expanded like this :
now the problem i am facing is that when i try to expand the last item of the recycler view , the view is expanded but we cannot understand as the recycler view does not scroll up. so it is expaned in real but since it is below the screen the user thinks that nothing has happened.
Like in the 1st image if we click on the last item, i.e. photograph the row is expanded but we donot understand untill we actually scroll it up like this :
so now how do i acheive this ? i mean if the last item on the screen is expanded how to i scroll it a bit up so the user understands the difference.
CODE :
#Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
if (holder instanceof ViewHolder)
{
final ViewHolder bodyholder = (ViewHolder) holder;
if (UtilInsta.PendingDoc.get(position).name.length() == 0) {
pd = new InstaDrawer();
bodyholder.penddoc_tv.setText(UtilInsta.PendingDoc.get(position).DOC_NAME);
if (UtilInsta.PendingDoc.get(position).ADDININFO_FLAG.equalsIgnoreCase("Y")) {
bodyholder.tv_clickforkyc.setVisibility(View.VISIBLE);
} else {
bodyholder.tv_clickforkyc.setVisibility(View.GONE);
}
bodyholder.pending_row.setId(position);
bodyholder.pending_row.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// crop(position);
InstaDrawer.pendingDocList= UtilInsta.PendingDoc.get(v.getId());
UtilInsta.setPosition(con, v.getId());
if (bodyholder.pend_ll.getVisibility() == View.VISIBLE) {
UtilInsta.PendingDoc.get(v.getId()).option = false;
bodyholder.pend_ll.setVisibility(View.GONE);
bodyholder.tv_clickforkyc.setVisibility(View.GONE);
if (bodyholder.remarks_layout.getVisibility() == View.VISIBLE) {
bodyholder.remarks_layout.setVisibility(View.GONE);
UtilInsta.PendingDoc.get(v.getId()).will_chek = false;
UtilInsta.PendingDoc.get(v.getId()).unable_chek = false;
}
} else {
bodyholder.pend_ll.setVisibility(View.VISIBLE);
// setHide(v.getId());
if (UtilInsta.PendingDoc.get(v.getId()).ADDININFO_FLAG.equalsIgnoreCase("Y")) {
bodyholder.tv_clickforkyc.setVisibility(View.VISIBLE);
} else {
bodyholder.tv_clickforkyc.setVisibility(View.GONE);
}
UtilInsta.PendingDoc.get(v.getId()).option = true;
if (UtilInsta.PendingDoc.get(v.getId()).MIN_DOC == "Y") {
bodyholder.provie_later.setVisibility(View.GONE);
bodyholder.unable_submit.setVisibility(View.GONE);
}
}
if(expandedpos>=0 && expandedpos!=v.getId())
{
int prev = expandedpos;
notifyItemChanged(prev);
}
expandedpos = v.getId();
}
});
// holder.acct_name_tv.setText(pendingDocLists.get(position).CUST_NAME);
bodyholder.camera.setId(position);
bodyholder.camera.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
InstaDrawer.pendingDocList= UtilInsta.PendingDoc.get(v.getId());
UtilInsta.setPosition(con, v.getId());
if (UtilInsta.PendingDoc.get(v.getId()).ADDININFO_FLAG.equalsIgnoreCase("Y")) {
if (Util.isNetworkConnected(con))
DocumentInfo(0, v.getId());
else
Util.shownointernet(con);
}
else {
UtilInsta.setFILE_NAME(con, "");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
( con.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || con.checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED)){
ActivityCompat.requestPermissions(((Activity)con),
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, com.app.hdfc.Manifest.permission.CAMERA},
MyConstants.READ_EXTERNAL_STORAGE_PERMISSION_CAM);
}
else
{
if(UtilInsta.PendingDoc.get(v.getId()).DOC_NAME.equalsIgnoreCase("Photograph"))
{
Intent intent = new Intent(con, FrontCamera.class);
UtilInsta.CUST_NO = UtilInsta.PendingDoc.get(v.getId()).CUST_NO;
(con).startActivity(intent);
((Activity)con).finish();
}else {
Intent intent = new Intent(con, CroppingActivity.class);
intent.putExtra("camera_gallery", 0);
intent.putExtra("fromRecycler", true);
intent.putExtra("position", v.getId());
intent.putExtra("DOC_NAME", UtilInsta.PendingDoc.get(v.getId()).DOC_NAME);
UtilInsta.doc_name = UtilInsta.PendingDoc.get(v.getId()).DOC_NAME;
Log.d("Recycler", UtilInsta.doc_name);
intent.putExtra("CUST_NO", UtilInsta.PendingDoc.get(v.getId()).CUST_NO);
(con).startActivity(intent);
((Activity) con).finish();
}
}
}
}
});
bodyholder.gallery.setId(position);
bodyholder.gallery.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
InstaDrawer.pendingDocList= UtilInsta.PendingDoc.get(v.getId());
UtilInsta.setPosition(con, v.getId());
if (UtilInsta.PendingDoc.get(v.getId()).ADDININFO_FLAG.equalsIgnoreCase("Y"))
if(Util.isNetworkConnected(con))
DocumentInfo(1, v.getId());
else
Util.shownointernet(con);
else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
con.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(((Activity)con),
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
MyConstants.READ_EXTERNAL_STORAGE_PERMISSION);
}
else {
UtilInsta.setFILE_NAME(con, "");
Intent intent = new Intent(con, CroppingActivity.class);
intent.putExtra("camera_gallery", 1);
intent.putExtra("fromRecycler", true);
intent.putExtra("position", v.getId());
intent.putExtra("DOC_NAME", UtilInsta.PendingDoc.get(v.getId()).DOC_NAME);
UtilInsta.doc_name = UtilInsta.PendingDoc.get(v.getId()).DOC_NAME;
Log.d("Recycler", UtilInsta.doc_name);
intent.putExtra("CUST_NO", UtilInsta.PendingDoc.get(v.getId()).CUST_NO);
(con).startActivity(intent);
((Activity) con).finish();
}
}
}
});
if (UtilInsta.PendingDoc.get(position).MIN_DOC.equalsIgnoreCase("Y")) {
bodyholder.provie_later.setVisibility(View.GONE);
bodyholder.unable_submit.setVisibility(View.GONE);
} else {
bodyholder.provie_later.setVisibility(View.VISIBLE);
bodyholder.unable_submit.setVisibility(View.VISIBLE);
}
bodyholder.provie_later.setId(position);
bodyholder.provie_later.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (remark == 1) {
remark = 0;
bodyholder.provie_later.setImageResource(R.drawable.circle1);
bodyholder.remarks_layout.setVisibility(View.GONE);
UtilInsta.PendingDoc.get(v.getId()).will_chek = false;
} else if (remark == 0 || remark == 2) {
bodyholder.unable_submit.setImageResource(R.drawable.circle2);
bodyholder.provie_later.setImageResource(R.drawable.circle1_hover);
remark = 1;
bodyholder.remarks_layout.setVisibility(View.VISIBLE);
UtilInsta.PendingDoc.get(v.getId()).will_chek = true;
}
}
});
bodyholder.unable_submit.setId(position);
bodyholder.unable_submit.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (remark == 2) {
remark = 0;
bodyholder.unable_submit.setImageResource(R.drawable.circle2);
bodyholder.remarks_layout.setVisibility(View.GONE);
UtilInsta.PendingDoc.get(v.getId()).unable_chek = false;
} else if (remark == 0 || remark == 1) {
bodyholder.provie_later.setImageResource(R.drawable.circle1);
bodyholder.unable_submit.setImageResource(R.drawable.circle2_hover);
remark = 2;
bodyholder.remarks_layout.setVisibility(View.VISIBLE);
UtilInsta.PendingDoc.get(v.getId()).unable_chek = true;
}
}
});
bodyholder.tv_clickforkyc.setId(position);
bodyholder.tv_clickforkyc.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (Util.isNetworkConnected(con))
DocumentInfo(2, v.getId()); // 2 for kyc list
else
Util.shownointernet(con);
}
});
bodyholder.remarks_submit.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String remark_str = bodyholder.remarks_edittext.getText().toString().trim();
if (remark_str.equalsIgnoreCase("")) {
Toast.makeText(con, "Please enter some remark", Toast.LENGTH_LONG).show();
} else if (remark_str.length() > 100) {
Toast.makeText(con, "Please enter remark less than 100 characters", Toast.LENGTH_LONG).show();
} else {
//Toast.makeText(con, "Remark : " + remark + " Submitted", Toast.LENGTH_LONG).show();
String remarktype = "";
if (remark == 1) {
remarktype = "PROVIDE_LATER";
} else if (remark == 2) {
remarktype = "NOT_AVAILABLE";
}
Log.e("Remarktype", remarktype + "1 " + remark);
if(Util.isNetworkConnected(con)) {
uploddoc(remarktype, remark_str);
bodyholder.remarks_edittext.setText("");
}
else
Util.shownointernet(con);
bodyholder.remarks_layout.setVisibility(View.GONE);
bodyholder.pend_ll.setVisibility(View.GONE);
UtilInsta.PendingDoc.get(position).option = false;
bodyholder.tv_clickforkyc.setVisibility(View.GONE);
}
}
});
// if (!UtilInsta.PendingDoc.get(position).REMARKS.equalsIgnoreCase("")) {
// bodyholder.remarks_tv.setVisibility(View.VISIBLE);
// bodyholder.remarks_tv.setText("*Remark - " + UtilInsta.PendingDoc.get(position).REMARKS);
if (UtilInsta.PendingDoc.get(position).STATUS.equalsIgnoreCase("NOT_AVAILABLE")) {
bodyholder.remarks_tv.setVisibility(View.VISIBLE);
bodyholder.remarks_tv.setText("*Remark - " + UtilInsta.PendingDoc.get(position).REMARKS);
bodyholder.unable_submit.setImageResource(R.drawable.circle2_hover);
bodyholder.provie_later.setImageResource(R.drawable.circle1);
bodyholder.remarks_edittext.setText(UtilInsta.PendingDoc.get(position).REMARKS);
UtilInsta.PendingDoc.get(position).unable_chek =true;
} else if (UtilInsta.PendingDoc.get(position).STATUS.equalsIgnoreCase("PROVIDE_LATER")) {
bodyholder.remarks_tv.setVisibility(View.VISIBLE);
bodyholder.remarks_tv.setText("*Remark - " + UtilInsta.PendingDoc.get(position).REMARKS);
bodyholder.unable_submit.setImageResource(R.drawable.circle2);
bodyholder.provie_later.setImageResource(R.drawable.circle1_hover);
bodyholder.remarks_edittext.setText(UtilInsta.PendingDoc.get(position).REMARKS);
UtilInsta.PendingDoc.get(position).will_chek =true;
}
else {
bodyholder.remarks_tv.setVisibility(View.GONE);
bodyholder.unable_submit.setImageResource(R.drawable.circle2);
bodyholder.provie_later.setImageResource(R.drawable.circle1);
bodyholder.remarks_edittext.setText("");
}
bodyholder.pending_row.setVisibility(View.VISIBLE);
bodyholder.acct_name_tv.setVisibility(View.GONE);
if (UtilInsta.PendingDoc.get(position).unable_chek) {
bodyholder.provie_later.setImageResource(R.drawable.circle1);
bodyholder.unable_submit.setImageResource(R.drawable.circle2_hover);
bodyholder.remarks_layout.setVisibility(View.VISIBLE);
UtilInsta.PendingDoc.get(position).unable_chek = true;
} else {
bodyholder.unable_submit.setImageResource(R.drawable.circle2);
bodyholder.remarks_layout.setVisibility(View.GONE);
UtilInsta.PendingDoc.get(position).unable_chek = false;
}
if (UtilInsta.PendingDoc.get(position).will_chek) {
bodyholder.unable_submit.setImageResource(R.drawable.circle2);
bodyholder.provie_later.setImageResource(R.drawable.circle1_hover);
bodyholder.remarks_layout.setVisibility(View.VISIBLE);
UtilInsta.PendingDoc.get(position).will_chek = true;
} else {
bodyholder.provie_later.setImageResource(R.drawable.circle1);
bodyholder.remarks_layout.setVisibility(View.GONE);
UtilInsta.PendingDoc.get(position).will_chek = false;
}
if (UtilInsta.PendingDoc.get(position).option) {
bodyholder.pend_ll.setVisibility(View.VISIBLE);
if (UtilInsta.PendingDoc.get(position).ADDININFO_FLAG.equalsIgnoreCase("Y")) {
bodyholder.tv_clickforkyc.setVisibility(View.VISIBLE);
} else {
bodyholder.tv_clickforkyc.setVisibility(View.GONE);
}
UtilInsta.PendingDoc.get(position).option = true;
if (UtilInsta.PendingDoc.get(position).MIN_DOC == "Y") {
bodyholder.provie_later.setVisibility(View.GONE);
bodyholder.unable_submit.setVisibility(View.GONE);
}
} else {
bodyholder.pend_ll.setVisibility(View.GONE);
bodyholder.tv_clickforkyc.setVisibility(View.GONE);
if (bodyholder.remarks_layout.getVisibility() == View.VISIBLE) {
bodyholder.remarks_layout.setVisibility(View.GONE);
UtilInsta.PendingDoc.get(position).will_chek = false;
UtilInsta.PendingDoc.get(position).unable_chek = false;
}
}
} else if (UtilInsta.PendingDoc.get(position).name.length() > 0) {
bodyholder.pending_row.setVisibility(View.GONE);
bodyholder.acct_name_tv.setVisibility(View.VISIBLE);
bodyholder.acct_name_tv.setText(UtilInsta.PendingDoc.get(position).name);
//continue comeback;
}
if(expandedpos == position)
{
bodyholder.pend_ll.setVisibility(View.VISIBLE);
if(UtilInsta.PendingDoc.get(position).option)
bodyholder.tv_clickforkyc.setVisibility(View.VISIBLE);
else
bodyholder.tv_clickforkyc.setVisibility(View.GONE);
}else
{
bodyholder.pend_ll.setVisibility(View.GONE);
bodyholder.tv_clickforkyc.setVisibility(View.GONE);
}
}else if (holder instanceof FooterViewHoldrer){
FooterViewHoldrer footerViewHoldrer = (FooterViewHoldrer) holder;
if(UtilInsta.PendingDoc.size()==0)
{
footerViewHoldrer.empty_pendingdoc.setVisibility(View.VISIBLE);
footerViewHoldrer.pending_continue.setVisibility(View.GONE);
footerViewHoldrer.loan_sanctioned.setVisibility(View.GONE);
}
else
{
footerViewHoldrer.empty_pendingdoc.setVisibility(View.GONE);
footerViewHoldrer.pending_continue.setVisibility(View.VISIBLE);
footerViewHoldrer.loan_sanctioned.setVisibility(View.VISIBLE);
}
if(submit_activate)
{
footerViewHoldrer.pending_continue.setBackgroundResource(R.drawable.background_button);
}else
{
footerViewHoldrer.pending_continue.setBackgroundResource(R.color.myblack);
}
footerViewHoldrer.pending_continue.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if(submit_activate) {
// Toast.makeText(con,"Button Activated.",Toast.LENGTH_SHORT).show();
if(Util.isNetworkConnected(con))
new UpdateStep().execute();
else
Util.shownointernet(con);
}else
{
Toast.makeText(con,"Submit/Remark all Documents",Toast.LENGTH_SHORT).show();
}
}
});
}
}
Try This:
yourRecyclerView.scrollToPosition(position);
the variable position will be having the value of the expanded position.
I am trying to dynamically set message to AlertDialog.Builder ,
but when i run the app , no message is shown. I want the message to be changed according to the text the user types on some editText widgets.
Any advice appreciated.
private AlertDialog.Builder builder;
private AlertDialog dialog;
private CharSequence alertMessage;
// set AlertMessage
public CharSequence setAlertMessage() {
if (editText0.getText().toString().equals("το αγόρι") &&
editText1.getText().toString().equals("το κορίτσι") &&
editText2.getText().toString().equals("ένας άντρας") &&
editText3.getText().toString().equals("μια γυναίκα")) {
alertMessage = ("Συγχαρηρήρια! Πάτησε ΟΚ για να\nπροχωρήσεις στην επόμενη διεπαφή");
} else if (editText0.getText().toString().equals("το αγορι") &&
editText1.getText().toString().equals("το κοριτσι") &&
editText2.getText().toString().equals("ενας αντρας") &&
editText3.getText().toString().equals("μια γυναικα")) {
alertMessage = ("Μάλλον ξέχασες τους τόνους!\nΞαναπροσπάθησε");
} else if (editText2.getText().toString().equals("o άντρας") || editText2.getText().toString().equals("ο αντρας") &&
editText3.getText().toString().equals("η γυναίκα") || editText3.getText().toString().equals("η γυναικα")) {
alertMessage = ("Μάλλον ξέχασες τις αόριστες αντωνυμίες\n(ενας , μια)\nΠάτησε ΟΚ για να ξαναπροσπαθήσεις");
}
return alertMessage;
}
dialog = builder.create();
basicsBtn2.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (editText0.getText().toString().equals("το αγόρι") &&
editText1.getText().toString().equals("το κορίτσι") &&
editText2.getText().toString().equals("ένας άντρας") &&
editText3.getText().toString().equals("μια γυναίκα")) {
dialog.show();
}
else if (editText0.getText().toString().equals("το αγορι") &&
editText1.getText().toString().equals("το κοριτσι") &&
editText2.getText().toString().equals("ενας αντρας") &&
editText3.getText().toString().equals("μια γυναικα")) {
dialog.show();
}
else if (editText2.getText().toString().equals("o άντρας") || editText2.getText().toString().equals("ο αντρας") &&
editText3.getText().toString().equals("η γυναίκα") || editText3.getText().toString().equals("η γυναικα")) {
dialog.show();
}
else {
Toast.makeText(getApplicationContext(),"Έκανες κάποιο λάθος!Ξαναπροσπάθησε.",Toast.LENGTH_SHORT).show();
}
}
});
builder.setMessage(setAlertMessage());
When you built your dialog you have to create them by method create() from Builder class and after that you have to display it by method show() from Dialog class.
You have to change way how you display dialog after click on:
basicsBtn2.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (editText0.getText().toString().equals("το αγόρι") &&
editText1.getText().toString().equals("το κορίτσι") &&
editText2.getText().toString().equals("ένας άντρας") &&
editText3.getText().toString().equals("μια γυναίκα")) {
new AlertDialog.Builder(YourActivity.this).setMessage(setAlertMessage()).create().show();
}
else if (editText0.getText().toString().equals("το αγορι") &&
editText1.getText().toString().equals("το κοριτσι") &&
editText2.getText().toString().equals("ενας αντρας") &&
editText3.getText().toString().equals("μια γυναικα")) {
new AlertDialog.Builder(YourActivity.this).setMessage(setAlertMessage()).create().show();
}
else if (editText2.getText().toString().equals("o άντρας") || editText2.getText().toString().equals("ο αντρας") &&
editText3.getText().toString().equals("η γυναίκα") || editText3.getText().toString().equals("η γυναικα")) {
new AlertDialog.Builder(YourActivity.this).setMessage(setAlertMessage()).create().show();
}
else {
Toast.makeText(getApplicationContext(),"Έκανες κάποιο λάθος!Ξαναπροσπάθησε.",Toast.LENGTH_SHORT).show();
}
}
How to write all writeCharacteristics in a loop in ble in android.code is as follows
in this method i pass 3 writecharacteristic() and only one is write and others are ignored.
if (beartoggle.isChecked()) {
if (mDeviceLight.equalsIgnoreCase("on") && mDeviceAlarm.equalsIgnoreCase("on")) {
byte[] val = {1};
if (check_port_1 == 1) {
mBluetoothLeService.writeCharacteristic(val, 1);
}
if (check_port_2 == 1) {
mBluetoothLeService.writeCharacteristic(val, 2);
}
if (find_me == 1) {
mBluetoothLeService.writeCharacteristic(val, 3);
}
}
}
and someone is saying use public void onReliableWriteCompleted() and check if port1 is written then go to port2 and then findme. This method will help me, if yes then how ? Please send me clear details and following is my writeCharacteristic()
public boolean writeCharacteristic(byte value[], int type) {
//check mBluetoothGatt is available
if (mBluetoothGatt == null) {
Log.e(TAG, "lost connection");
return false;
}
BluetoothGattService Service = mBluetoothGatt.getService(UUID_SIMPLESERVICE);
if (Service == null) {
Log.e(TAG, "service not found!");
return false;
}
BluetoothGattCharacteristic charac1 = null;
BluetoothGattCharacteristic charac2 = null;
BluetoothGattCharacteristic charac3 = null;
boolean status1 = false, status2 = false, status3 = false;
Log.v("___TYPE___", "________1______________" + (type == 1));
Log.v("___TYPE___", "________2______________" + (type == 2));
Log.v("___TYPE___", "________3______________" + (type == 3));
onReliableWriteCompleted(status1);
onReliableWriteCompleted(status2);
onReliableWriteCompleted(status3);
if (type == 1) {
charac1 = Service.getCharacteristic(UUID_PORT1);
charac1.setValue(value);
status1 = mBluetoothGatt.writeCharacteristic(charac1);
Log.v("________BLESERVICE____", "___WRITE CHARATERISTICS STATUS:_________" + status1);
onReliableWriteCompleted(status1);
} else if (type == 2) {
charac2 = Service.getCharacteristic(UUID_PORT2);
charac2.setValue(value);
status2 = mBluetoothGatt.writeCharacteristic(charac2);
onReliableWriteCompleted(status2);
Log.v("________BLESERVICE_______", "___WRITE CHARACTERISTICS STATUS_______" + status2);
} else if (type == 3) {
charac3 = Service.getCharacteristic(UUID_FINDME);
charac3.setValue(value);
status3 = mBluetoothGatt.writeCharacteristic(charac3);
onReliableWriteCompleted(status3);
Log.v("__________BLESERVICE_________", "___WRITE CHARACTERISTICS STATUS_____" + status3);
}
if (charac1 == null && charac2 == null && charac3 == null) {
Log.e(TAG, "char not found!");
return false;
}
Log.v("___TYPE___", "______________________" + type);
return status1 && status2 && status3;
}
call BluetoothLeService.getSupportedGattServices(), you will get a list of services. Iterate through it and call BluetoothGattService.getCharacteristics(). You will again get a list, you can iterate through it.
For more info, you can refer this
Hi all I am using a splash activity for first time or he is logged out from my app. But this appear frequently on Samsung galaxy S2. This my activity onCreate() method code
private static EditText serverIP = null;
String mMDCServerIP = "";
String skipSplashScreenStatus = null;
String mSplashScreenRunningStatus = null;
String mDeniedStatusFromServer = null;
public void onCreate(Bundle savedInstance)
{
super.onCreate(savedInstance);
/** Get the MDC IP **/
Log.d("splash","1111111111111111");
skipSplashScreenStatus = Config.getSetting(getApplicationContext(),"SPLASHSTATUS");
mSplashScreenRunningStatus = Config.getSetting(getApplicationContext(),"SPLASHACTIVITYRUNNINGSTATUS");
mDeniedStatusFromServer = Config.getSetting(getApplicationContext(),"DENYSTATUS");
if(skipSplashScreenStatus == null || skipSplashScreenStatus.length() == 0)
{
Config.setSetting(getApplicationContext(),"DENYSTATUS","false");
}
/** If SPLASHSTATUS does not exist then store the SPLASHSTATUS as false**/
if(skipSplashScreenStatus == null || skipSplashScreenStatus.length() == 0)
{
Config.setSetting(getApplicationContext(),"SPLASHSTATUS","false");
}
if(mSplashScreenRunningStatus == null || mSplashScreenRunningStatus.length() == 0)
{
Config.setSetting(getApplicationContext(),"SPLASHACTIVITYRUNNINGSTATUS","yes");
}
Log.d("splash","222222222222222222");
Log.d("splash","skipSplashScreenStatus : "+skipSplashScreenStatus);
skipSplashScreenStatus = Config.getSetting(getApplicationContext(),"SPLASHSTATUS");
if(skipSplashScreenStatus!= null && skipSplashScreenStatus.equalsIgnoreCase("yes"))
{
Log.d("splash","inside if condition");
skipSplashScreen();
}
else{
Log.d("splash","inside else condition");
setContentView(R.layout.splash_screen);
Log.d("SPLASH","33333333333333");
serverIP = (EditText) findViewById(R.id.splash_server_ip);
/** Get the MDC IP **/
mMDCServerIP = Config.getSetting(getApplicationContext(),"IPADDR");
/** If MDC IP does not exist then store the IP as 0.0.0.0**/
if(mMDCServerIP == null || mMDCServerIP.length() == 0)
{
Config.setSetting(getApplicationContext(),"IPADDR","0.0.0.0");
}
serverIP.setOnEditorActionListener(new EditText.OnEditorActionListener()
{
#Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH ||
actionId == EditorInfo.IME_ACTION_DONE ||
event.getAction() == KeyEvent.ACTION_DOWN &&
event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
Config.setSetting(getApplicationContext(),"SPLASHSTATUS","yes");
Config.setSetting(getApplicationContext(),"SPLASHACTIVITYRUNNINGSTATUS","no");
skipSplashScreen();
}}}}
Here is the code for skipSplashScreen();
private void skipSplashScreen()
{
try{
Log.d("splash","inside skipSplashScreen 111");
CommandHandler.mStopSendingKeepAlive = false;
Log.d("splash","inside skipSplashScreen 222");
startActivity(new Intent(getApplicationContext() ,SecondTest.class));
}
catch(Exception e)
{
Log.d("splash","Exception in skipSplashScreen 333");
Log.d("splash",e.getMessage());
}
}
Once i dig more into code it seems control is skipSplashScreen() method but not starting second activity. May i know what can be the reason.
Try this, when starting the activity, use Activity.this instead of getApplicationContext()
private void skipSplashScreen()
{
try{
Log.d("splash","inside skipSplashScreen 111");
CommandHandler.mStopSendingKeepAlive = false;
Log.d("splash","inside skipSplashScreen 222");
startActivity(new Intent(SplashScreen.this ,SecondTest.class));
}
catch(Exception e)
{
Log.d("splash","Exception in skipSplashScreen 333");
Log.d("splash",e.getMessage());
}
}