[Solved] String to find A character [duplicate]

If you’re beginner check this : String s1=” read the documentation for the methods of String”; //your string char ch=s1.charAt(s1.indexOf(‘A’)); //first appearance of character A int count = 0; for(int i=0;i<s1.length();i++) { if(s1.charAt(i)==’A’){ //if character at index i equals to ‘A’ System.out.println(“number of A:==”+ch); count++; //increment count } } System.out.println(“Total count of A:==”+count); If you’re … Read more

[Solved] Advanced AlarmManager situation [closed]

You can use setRepeating(..) – which is described in detail here. If you want to repeat the alarm in an interval that is not provided in the available constants just calculate the correct amount of milliseconds (e.g. for a week: 1000 * 60 * 60 * 24 * 7 (1 sec * 60 -> 1 … Read more

[Solved] If the first name, last name and the nick name starts with the special chars [closed]

You can use String#matches() to check if a name begins with any of the special characters on your blacklist: if (name.matches(“(?:!|@|#|\\$|%|\\^|&|\\*|\\(|\\)|_|\\+|\\?|>|‌​<).*”)) { System.out.println(“Enter valid name”); } Another way: String specialChars = “!@#$%^&*()_+?><“; if (specialChars.indexOf(name.charAt(0)) != -1) { System.out.println(“Enter valid name”); } solved If the first name, last name and the nick name starts with the … Read more

[Solved] when user type abc xyz then show it as abc#xyz on screen

try this way. edittext.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) {} public void onTextChanged(CharSequence s, int start, int before, int count) { String result = s.toString().replaceAll(” “, “#”); if (!s.toString().equals(result)) { ed.setText(result); ed.setSelection(result.length()); } } }); 1 solved when user type abc xyz … Read more

[Solved] How to know which Button was pressed recently among all the Buttons in an activity?

Keep a local variable and set it to the appropriate button’s id whenever a button is pressed. int lastPressedButton; … @Override public void onClick(View v) { lastPressedButton = v.getId(); switch(v.getId()) { // normal button handling code } } 0 solved How to know which Button was pressed recently among all the Buttons in an activity?

[Solved] XML to Java code in Android [closed]

You can inflate its views by doing: LayoutInflater inflater = (LayoutInflater)context.getSystemService (Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(…); Alternatively, you can simply create a view like final LinearLayout l = […] //add stuff l.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); //etc… solved XML to Java code in Android [closed]

[Solved] Wondering why my app crashes

Looking at your code it seems that you made a typo here: TextView DialogText=(TextView) findViewById(R.id.imageViewDialog); It should be TextView DialogText=(TextView) findViewById(R.id.textViewDialog); or whatever the name of the id for this TextView is. Apart from that, you need to learn to read the messages from the LogCat as they are often very informative. Cleary it says: … Read more