Skip to main content

Posts

Copy to clipboard

In my upcoming app, I have codes which I display. These are some times lengthy, and I want the app to be able to copy this to clipboard. Once it is in clipboard, users can paste it anywhere. So how do you copy some text from your app to clipboard. You need to use clipboard manager. Clipboard Manager This class sets and gets data for the clipboard using Clipdata objects.  You can get the object of this class using system service.  - using statement context.getSystemService(Context.CLIPBOARD_SERVICE) Example I have a dummy project with a button, onclick of which copies content to clipboard. Here is my activity file package com . hegdeapps . testapp ; import android.content.ClipData ; import android.content.ClipboardManager ; import android.support.v7.app.AppCompatActivity ; import android.os.Bundle ; import android.view.View ; import android.widget.Button ; import android.widget.TextView ; public class MainActivity extends AppCompa
Recent posts

Hundred - a number game updated

Shataka - my number game which is very simple but really good, has been updated. First of all, its name is changed to "Hundred". Because that is the aim of the game, right? There are some UI changes too. May be for better :) :) And I have added a how to section, which guides the user step by step. The game has a grid of 9 cells , 3 rows and 3 columns. The aim of the game is to fill this grid with  numbers so that each row and each column adds up to 100. And all the required numbers are given at the bottom of the grid. In this version( v 3.0), in level 1,  6 numbers are already provided in the grid. (In older versions 3 numbers were filled in the grid). So user needs to fill only 3 more numbers. So level 1 is pretty easy. You can see that in the above screen shot, 2nd row and 3rd column are already filled and their sums are 100. In level 2, 5 numbers are provided and user should fill the remaining 4. And so on. From level 8 onwards, the game is slightly

Using a list fragment with cursor adapter

All these days, I avoided using fragments. But then I realized for my this particular applications fragments are ideal. I have a master - detail list in my app. Let us say you want to have two fragments - one is a fragment which contains a list of elements and second one expands one element of the list. Both of them share the same cursor from the activity. Let us start with list fragment. Do not try creating list fragment using a wizard. It unnecearrily adds too many methods and classes. Let us start writing our own fragment like this class MyListFragment extends ListFragment { } Next using code menu override option, override the following method onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) This method should be used for inflating the layout file for the fragment.  I have a framelayout in parent activity of this fragment with the id as container. So I will specify that for inflating. The framelayout will be the parent vi

Financial Calculator published

Today I have published my 7th app Financial Calculator in google play. (you will see 8 apps in market page. But Kannada Hindi keyboard is no longer supported as Akshara keyboard is its successor.) This app is meant for us Indians who want to save our money a little bit in FDs and RDs. Or/and pay EMI each month for housing and other loans. The app can calculate EMI amount, FD or RD maturity value. (So you can correct the bank official if they make a mistake :) ) It will also calculate how much will you pay extra for the loan. It lets you compare two loans, compare two FDs or RDs. There are other calculations too. Gratuity calculator, loan afford ability calculator, savings goal calculator and currency converter. So what are you waiting for? Download app today and give me your valuable feedback.

Ratings and feedbacks

Once your android project is at the finishing stage, you need to add the following extra features to your app. Rate the app Because rates drive app download Other apps by you free advertisement for your apps Send feedback you need them to remove bugs and improve the app Well, I personally feel that the pop up screens which ask the user to rate the app, is not a good idea. People may get irritated by this. But to provide the first one, you need to know the playstore page of your app. How do you get the page if you have not yet published the page? Well, the app page always looks like this https://play.google.com/store/apps/details?id =your_app_package_name    the last part is your package name of the app. And to take the user to all apps by you, you need to use a url like this https://play.google.com/store/apps/developer?id=yourdevelopername  So these two settled, let us write our xml and code <?xml version="1.0" encoding="utf-8&q

Using spinners in android

Spinner in android is a view which shows you a drop down menu and lets you select one of the items. Let us see how to use a spinner in your android program. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:app= "http://schemas.android.com/apk/res-auto" xmlns:tools= "http://schemas.android.com/tools" android:layout_width= "match_parent" android:layout_height= "match_parent" android:orientation= "vertical" app:layout_behavior= "@string/appbar_scrolling_view_behavior" tools:context= "com.hegdeapps.myapplication.MainActivity" tools:showIn= "@layout/activity_main" > <TextView android:id= "@+id/textView" android:layout_width= "wrap_content" android:layout_height= "wrap_content" an

Actionbar and toolbar using support library

Action bar has been our friend since a long time. But it has its own drawbacks. You can not change its color, or size or appearance of its elements. So came toolbar in android Lollipop. The beauty of this is, you add a toolbar like any other item in the layout xml file, set its color, size, position. Then add a few lines of code to make it an action bar. So let us dive straight into coding. I am using support library for toolbar and also appcompat activity. If you do not want to bother about devices with older versions than 5.0, you can straight use toolbar. You can find toolbar in appcompat option in Android studio design view of your xml file. So you insert that toolbar in the layout xml file. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android= "http://schemas.android.com/apk/res/android" android:orientation= "vertical" android:layout_width= "match_parent"   android:layout_margin=