Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

EditText.setOnKeyListener not working on maxLines EditText



Check this in XML file if use singleLine
singleLine change to maxLines (1 if singleLine)
declare inputType


        android:maxLines="1"
        android:inputType="text"


397LW NO topic_id



Další témata ....(Topics)


279

How To Check New Version Of Application Android Code | how-to-check-new-version-of-application-android-code



private int _nVersionCode = 0;	
private boolean _bNewVersion = false;


// onCreate
     	 _nVersionCode   = this.getPackageManager()
     	.getPackageInfo(this.getPackageName(), 0).versionCode;
     	Log.d(String.valueOf(_nVersionCode), "versionCode");

// onStart loadPreferences
 public void loadPreferences() {
			//SharedPreferences settings = getSharedPreferences(F.PREFERENCES_NAME, 0);
			SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
		int nOldVersionCode =	settings.getInt("_nVersionCode",  0);// old vesion
		if(_nVersionCode > nOldVersionCode)
			_bNewVersion = true;
	}

// onDestroy savePreferences	
	public void savePreferences() {
			SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
			SharedPreferences.Editor editor = settings.edit();
			editor.putInt("_nVersionCode", _nVersionCode); // save current version code
			editor.commit();
	}


354

How to test dual panels - panes fragments on small device screen Android | how-to-test-dual-panels-fragments-on-small-device-screen-android


If You have old PC (Android in emulator with high screen resolution uses a lot of memory) or your testing phone have small screen, You can try this trick.
Rename layout folder for small device screen f.g. from layout into layout-swXXXdp and a large layout-sw600dp into layout.
Your phone with small screnn will do select xml file from renamed layout folder (for small screen).
You can to testing rotation with device en stability of fragments if an application changed orientation.
If you have old pc, you can try to make a new virtual device running on older version of Android, which uses less memory of computer.
For testing of rotation stability - application orientation changed - use on emulator Ctrl+F11, Ctrl+F12 key (Windows).

Important
Before the release of application, you have to rename layout folder to older name layout-sw600dp and layout-swXXXdp to layout.
150

drawBitmap, clipPath, UNION, DIFFERENCE, INTERSECT, REPLACE, XOR Android example | drawbitmap-clippath-union-difference-intersect-replace-xor-android-example



public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new SampleView(this));
	}

	private static class SampleView extends View {

		// CONSTRUCTOR
		public SampleView(Context context) {
			super(context);
			setFocusable(true);

		}

		@Override
		protected void onDraw(Canvas canvas) {
			Paint paint = new Paint();

			canvas.drawColor(Color.YELLOW);

			 Bitmap b = Bitmap.createBitmap(200, 200,
			 Bitmap.Config.ARGB_8888);

			// you need to insert a image flower_blue into res/drawable folder

			paint.setFilterBitmap(true);
			Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),
					R.drawable.flower_blue);
			canvas.drawBitmap(bitmapOrg, 10, 10, paint);
			int width, height;

		    Canvas c = new Canvas(b);
		    paint.setAlpha(255); //0x80
		    c.translate(0, 30);
		    c.drawBitmap(bitmapOrg, new Matrix(), paint);
		    paint.setColor(Color.BLUE);
        Path mPath = new Path();
		    mPath.addCircle(50, 50, 50, Path.Direction.CCW);
            //c.clipPath(mPath, Region.Op.UNION);
            //c.clipPath(mPath, Region.Op.DIFFERENCE);
            c.clipPath(mPath, Region.Op.INTERSECT);
            //c.clipPath(mPath, Region.Op.REPLACE);
            //c.clipPath(mPath, Region.Op.XOR);
           paint.setColor(Color.GREEN);
           paint.setAntiAlias(true);
           c.drawCircle(30, 20, 30, paint);

		    int h = bitmapOrg.getHeight();
			//canvas.drawBitmap(bitmapOrg, 10, 10, paint);
			canvas.drawBitmap(b, 0, 10 + h + 10, paint);

		}

	}
}



bitmap xor android


regions
60

Get all ID from xml file for Android developers utility | get-all-id-from-xml-file-for-android-developers-utility


This software allow find all IDs from xml layout file source code and create variables with findViewById for onCreate, for onClick and load save preferences functions.
Get all ID is for Windows XP and higher.

2017,04,28
Download 1.0.2.0

[caption id="attachment_903" align="alignleft" width="300" caption="Get all ID from xml file for Android developers utility."]get-all-id-from-xml-file-android[/caption]
137

Draw drawARGB() Android basic example | draw-drawargb-android-basic-example



public class MainActivity extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new SampleView(this));
	}

	private static class SampleView extends View {

		// CONSTRUCTOR
		public SampleView(Context context) {
			super(context);
			setFocusable(true);

		}
		@Override
		protected void onDraw(Canvas canvas) {
			//drawARGB (int a, int r, int g, int b)
//			a  alpha component (0..255) of the color to draw onto the canvas 
//			r  red component (0..255) 
//			g  green component (0..255)  
//			b  blue component (0..255)  

			canvas.drawARGB(255, 0, 255, 10); 
		}

	}
}




Editace Jana Žákovská : 2017-02-14 14:41:51
Počet článků v kategorii: 397
Url:edittext-setonkeylistener-not-working-on-maxlines-edittext
Share
Share
Tweet