Skip to main content

Posts

Character and Word count in Android simple example

Here is the example of word count and character count in android using TextWatcher Activity: import android.graphics.Color; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.text.Editable; import android.text.TextWatcher; import android.view.Menu; import android.view.MenuItem; import android.widget.EditText; import android.widget.TextView; public class CharacterCount extends ActionBarActivity implements TextWatcher { EditText InputEDT; TextView WordCountTXT,CharCountTXT; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_character_count); InputEDT=(EditText)findViewById(R.id.editText1); CharCountTXT=(TextView)findViewById(R.id.textView2); WordCountTXT=(TextView)findViewById(R.id.textView1); InputEDT.addTextChangedListener(this); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().infl...

Splash Screen in Android with Animation

  Steps: 1. Create new project. 2. Now insert below code in SplashActivity /*********************************************  SplashScreen.java   ***********************************************/ public class SplashScreen extends Activity { private long ms = 0; private long splashDuration = 5000; private boolean splashActive = true; private boolean paused = false; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash_screen); AnimateScreen(); } private void AnimateScreen() { // TODO Auto-generated method stub Animation anim = AnimationUtils.loadAnimation(SplashScreen.this, R.anim.alpha); anim.reset(); RelativeLayout l=(RelativeLayout) findViewById(R.id.RelativeLayout1); l.clearAnimation(); l.startAnimation(anim); anim = AnimationUtils.loadAnimation(SplashScreen.this, R.anim.translate); anim.reset(); TextView life = (TextView) findViewById(R.id.textVi...

How to create custom title in Android Application

Custom title is nothing but a layout you bind to your application's title bar. MainActivity.java package com.example.customtitlebar; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.view.Window; import android.widget.Button; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.activity_main); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.customheader); init(); } private void init() { // TODO Auto-generated method stub Button Left=(Button)findViewById(R.id.header_left_btn); Left.setText("BACK"); Left.setTextColor(Color.GRAY); Button Title=(Button)findViewById(R.id.header_text); Title.setText("Scorecard"); Title.setTextColor(Color.GRAY); Button Right=(Button)findViewById(R.id.header_right_...