Separating Lists with Headers in Android 0.9. Earlier today the latest Android 0.9 SDK was released, and it’s packed full of wonderful changes. As you play around, you might see ListViews split into sections using separating headers. (Example shown on the right is the browser settings list.) There isn’t an easy way of creating these separated lists, so I’ve put together SeparatedListAdapter which does it quickly. To summarize, we’re creating a new BaseAdapter that can contain several other Adapters, each with their own section headers.
First let’s create some simple XML layouts to be used for our lists: first the header view, then two item views that we’ll use later for the individual lists. Now let’s create the actual SeparatedListAdapter class which provides a single interface to multiple sections of other Adapters. Here’s the source for SeparatedListAdapter: As expected, it correctly prevents the section headers from being selected, and seamlessly stiches together the various Adapters. How to draw a bitmap transformed to fit a shape? It seems one again I have answered my own question. I still dont understand how drawBitmapMesh works but I can achieve what I want to by using the Camera object. The Camera object allows you to rotate 2D objects in 3D space. The following code snippet (very much test code) demonstrates what is required. @Override protected void dispatchDraw(Canvas canvas) { Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.grid_bitmap); final int viewWidth = this.getWidth(); final int viewHeight = this.getHeight(); final int bitmapWidth = bitmap.getScaledWidth(canvas); final int bitmapHeight = bitmap.getScaledHeight(canvas); float scaleX = viewWidth / (float) bitmapWidth; float scaleY = viewHeight / (float) bitmapHeight; int preCenterX = bitmapWidth / 2; int preCenterY = bitmapHeight / 2; int postCenterX = viewWidth / 2; int postCenterY = viewHeight / 2; Paint mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setFilterBitmap(true);
Implement a simple File Explorer in Android. It's a simple File Explorer in Android. The files information can be read using java.io.File, using the code: File f = new File(dirPath); File[] files = f.listFiles(); The name of the files/folders will be added in a ArrayList. If it's not the root, two more elements (the root and the parent) will be added in the front of the ArrayList. Then, the ArrayList will be adapted to a ArrayAdapter, and also set to be displayed on screen. In case any item is clicked; if it's a file, the name will be display in a dialog; if it's a directory (isDirectory) and can be read (canRead), will open the selected directory; if it's a directory and CANNOT be read, a message will be prompt.
Create a layout file /res/layout/row.xml, which is the layout of each row the the list. Modify /res/layout/main.xml to have a List: remark: TextView with id empty will be display IF the list is empty. Modify the code, AndroidExplorer.java. How To Save and Load External Images in Google Android. Saving Images Now we'll look at the case where we take a picture with the camera using the 'How to Program the Android Camera to Take Pictures' tutorial.
When we take a picture, we receive a byte array... what do we do with this? How can we convert this to a image in our SD card? Let's do it. We create a File object with the place where to store the images. File sdImageMainDirectory = "/sdcard/myImages"; We initialize some variables. FileOutputStream fileOutputStream = null; The image file name String nameFile = “myImage” Now, the quality of the image. Int quality = 50; We create the options we are going to use in our compression (adding the sample size) BitmapFactory.Options options=new BitmapFactory.Options(); options.inSampleSize = 5; We create the Bitmap from the imageData (byte array) and we throw it to the FileOutputStream with the name and the compression given (In this case JPEG) Bitmap myImage = BitmapFactory.decodeByteArray(imageData, 0,imageData.length,options); bos.flush(); bos.close(); Numeric editText and EditText with max number of characters... yes, again !
Sometimes, being a lone developer is a very depressing status.You want a feature, you fight with the system, the tools, the documentations ( no comment ), the forums, ...And you found a solution. So you're happy with all your code that do what you wanted.Until you finally find you could achieve the same thing with only one line of code ! This is exactly what happened to me ! I found that a numeric editText ( or a textView) is done with this XML tag : android:numeric="decimal" Then I found that limiting the number of character is also very simple : android:maxLength="10" and that's all !
Why didn't I find that in the first time ( and spend so many time on my own solution ? InputFilter[] FilterArray = new InputFilter[1];FilterArray[0] = new InputFilter.LengthFilter(8);editEntryView.setFilters(FilterArray); For the numeric editText, there is also a obscur solution : So all my work was useless ? How to show Alerts to the user in the Android programming Environment. Android resolution and layout problems | Mobile Solutions Blog. During the process of developing I think I spider we discovered various problems regarding Android's different resolutions. Here you can see which problems we encountered and how we solved them: We are being told that we should not use the AbsoluteLayout , but what if there is no other choice of implementing your layout except for using the AbsoluteLayout? What If the layout needs to have some views to overlay each other so that it fits nicely?
This was exactly the case for us this time. In the layout for I think I spider there are a few ImageViews (with changing images) that simply have to be on top of others or even in the area of the tabs, and they also have to be at this EXACT position of the other image on every resolution. Dp or not dp? It was some work, but after a little time, the layout fitted for each density - well, at least so it seemed... The problem was, that we used (as we are also said to always use) dp to set the views. Changing the layout in your code Conclusion. Override back button.
View topic - Seekbar (progressbar) customizing. How to provide animation when calling another activity in Android.