WHAT'S NEW?
Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts
In the last 2 days, I have tried installing multiple Android Emulators out there on the internet. I will now start writing the review on those one after the other.
I would like to start this with Andy emulator, the one that had tortured me and literally harrasd me.

The biggest downsides of Andy are:

  1. It took away a huge piece of disk space. It took 4.5 GB space.
  2. Leave about eating away space, the biggest disadvantage is that it did not give me an option during setup to change the location of the installation. It by default installed everything in C drive. What the Heck! is this.
  3. It took close to an hour to install on a machine that runs on i5 Intel, with 4 processors and an internet speed on 8GB. BS! a real BS.
  4. I did not show what all are its dependencies. Half way through, it started asking me permissions to install Java Virtual Box softwares of multiple types. One more BS. This made me stick to my seat staring at my monitor.

I felt like i will puke (vomit) on my laptop screen before it finishes. Thanks to my mom, she gave me a needed break with a wonderful coffee. 





Recently we had a requirement where we have to display data in a list in android. Every row in the list has multiple TextView items. It means, we wanted an output that is like this!


Requirement:

  • The list items should have space division between them.
  • The default color of the listview item must be colored in gray+blue mix.
  • On touch/click of the item, it should highlight it as green.
  • Every item in the list has 3 elements (Header, content/information and datetime when the content was received)

So, how did I do it?


  • To achieve the colors needed for the project, that is default -gray and on hover - green, we did this


Add: Inside res/drawable, create a new resource file with the following name generic_list_row_selector.xml
Add the following code to it.


2nd, Add: gradient_background.xml which has the below code
3rd, Add gradient_background_hover.xml with the below code snippet in it

  • Open the main activity file's designer -> in my case it is MainActivity and its related designer calss is acitivity_main
Add the following code to it. This has the ListView that will show the list of items that we bind




  • Now we need the Row that has the TextView elements that displays the data for us. Create a new res file named activity_custom_row_for_listview.xml with the following code in it.



The data that will be bind to the controls - TextView will be from an object holder. So, create a java class named DisplayDataClass.java

Now, create a custom Adaptor, that will make sure to bind the controls with the data as the data is fed in and rebinds it with each item (row) of the listview. Create a file named CustomAdaptor.java


Comeback to the parent class now. It should have the below code




The method private ArrayList<DisplayDataClass> GetDisplayResults() inside the class MainActivity is the data object. You can plug in your own data and show it here. It might be from SQLite database or from an API or from GCM or from another Activity inside your android app. 

Hope, you have liked my tutorial. Stay tuned! there is a lot to come. - Eshwar




I feel good about myself. This was in 2014, Oct 03. I was talking to my friend late night (1:30 AM) over hangouts and I told him that soon we all will see companies/ businesses move to mobile app only way of communication.

And look at what has happened. A few weeks ago, Myntra, India's eCommerce site that sells clothing has plans to shutdown its website completely and do their business mobile only way! Yes, Flipkart, Indian origin eCommerce company, which owns Myntra said that they now have 70-80% of their sales from mobile app.

Here is a part of my chat with my friend 




Today, EconomicTimes, one of India's most popular newspaper on economics says that many companies are planning to move mobile only way so that they can easily make updates and other offers readily available to the end user via push services which is the easiest way to grab attention and make conversion!

Click here is the complete article. 



























These days, as part of my side project, I have started working with Android. There was a requirement to show type of travel (business, economy, tourist, etc.,) basis for the customer who is awaiting to check-in into our clients hotel.

Android gives us a simple spinner item that can be quickly built and used. Below is the sample. For the sake of the sample, i have hard coded the location names, instead of picking up from SQLlite.


for my MainActivity.xml, i have made it implement  AdapterView.OnItemSelectedListener .

Then, defined the spinner and its dataset
        //to read the spinner element
        Spinner spinner =(Spinner) findViewById(R.id.spinner);
        spinner.setOnItemSelectedListener(this);
        // Spinner Drop down elements
        List<String> categories = new ArrayList<String>();
        categories.add("Business");
        categories.add("Family trip");
        categories.add("back packing tourist");
        categories.add("delegation visitor");
        categories.add("Other Tourism ");


Then, i have set the Adaptor details for the ArrayList and the spinner to bind together.

// Creating adapter for spinner
        ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>
                                    (this, android.R.layout.simple_spinner_item, categories);

       // Drop down layout style
       dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

   // attaching data adapter to spinner
       spinner.setAdapter(dataAdapter);



Override the methods for onItemSelected

 @Override
    public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
        // On selecting a spinner item
        String item = adapterView.getItemAtPosition(position).toString();

        // Showing selected spinner item
        Toast.makeText(adapterView.getContext(), "Selected: " + item, Toast.LENGTH_LONG).show();
    }

    @Override
    public void onNothingSelected(AdapterView<?> adapterView) {

    }
here is the out come of the code in the emulator.