Tuesday, 13 September 2016

     We can easy to extract the timezone from current system time using javascript by the following code.




Example Program:- (Editor)


Editor is Loading...

Advertisement

Thursday, 18 August 2016

     In the following example we are going see about the webview and load some html code into the newly created webview in android, in the previous post we are seen about creating the webview and load the url into that webview


If you don't know how to create webview in android studio please click here

Code for load html code directly to webview
String html = "<html><body>This is the test webview</body></html>";
String mime = "text/html";
String encoding = "utf-8";









WebView myWebView = (WebView)this.findViewById(R.id.myWebView);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.loadDataWithBaseURL(null, html, mime, encoding, null);


Html code into webview

Monday, 15 August 2016

     In this tutorial we are going to learn about the android button and place a image on that button and give images on every states (pressed,focused and normal).

1) First create a new project in android studio more details...

2) Remove the TextView code from activity_main.xml, create a button in your project by the following code or tools.

<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="@drawable/btnhome_new" />


android add button in main_activity.xml

Note:
     In the above image you can see the error @drawable/btnhome_new. Because it will find the file btnhome_new.xml file on drawable directory, but we not yet created.

3) Now we are going to create a file btnhome_new.xml file on drawable directory.
   a) Right click on the drawable directory and => New => Drawable resource file
 
Create new xml file in android

   b) Now a file is opened btnhome_new.xml just remove all the code from that file and replace with the below code.

Note : After create this file the error(@drawable/btnhome_new) is removed from activity_main.xml.

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/btnblue"
android:state_pressed="true" />
<item android:drawable="@drawable/btnrose"
android:state_focused="true" />
<item android:drawable="@drawable/btnred" />
</selector>

Selector added in a xml file in android.jpeg

You can see some error on this code
@drawable/btnblue
@drawable/btnrose
@drawable/btnred

 Because btnBlue.jpg,btnRose.jpg and btnRed.jpg are not in drawable directory. 4) Now we are going to create all the files in drawable directory.
     Copy the images to drawable directory.

     Paste the copied images to drawable directory.
Paste the copied images to android drawable folder

     A dialog box will ask for confirmation, just press ok.
Paste dialog box in adndroid studio
     Now the images are placed into drawable folder, and you can see the above error was removed.

Successfully removed the error in android

Note : Image name should not contain capital letters.


Saturday, 13 August 2016

     In the following javascript code is used to create the html img tag dynamically and append it to the specified div in a loop.

Create Image tag using javacript
     Usually we are directly create the html tag in the html code, but if you want to create this img tag dynamically you can follow the below code.


   var img = document.createElement("img");

   img.src = "http://www.google.com/intl/en_com/images/logo_plain.png";



   var src = document.getElementById("elementid");

   src.appendChild(img);


Set multiple images in a loop
     If you want to add only one image, you can follow the above method. If you want to append more images dynamically you can follow the below method.



Example Program:- (Editor)


Editor is Loading...

Advertisement

Wednesday, 10 August 2016

     Webview is a tool in android studio and it is used to load html or website to mobile, through this we can easy to create the android application through html,css and javascript code.

1) First create a new project in android studio more details...

2) Open activity_main.xml file under the layout folder.

Open layout.xml file in android studio


3) Copy the following code to the activity_main.xml

<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>

xml code for creating webview


     When you add the code to activity_main.xml you can see the preview by clicking Design.


Webview Preview in design tab

4) You must set internet permission in AndroidManifest.xml. Open AndroidManifest.xml file and enter the following code.

<uses-permission android:name="android.permission.INTERNET" />

add android.permission.Internet user permission in android

5) Open MainActivity.java file and modify it by the below steps.
  
    a) import the following class
import android.webkit.WebView;
import android.webkit.WebViewClient;

    b) When you want to load the url to your webview, just call the below code.
        WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.setWebViewClient(new WebViewClient());
myWebView.loadUrl("http://www.google.com");


Java code for webview

6) Now you are done with your first webview, just run the code.


Java code for webview final output





Saturday, 6 August 2016

1) Open Android studio, then find the File option from the menu bar and go to New => New Project.





2) Now one new dialog box is open and ask the project details Application name, Company Domain and project location.

Application name
     No need to enter unique name compare with playstore, this name is displayed under the application icon.


Application name for android project
Company Domain
     It must be unique compare between the google play store (If you created the name and the same name already in playstore it won't show any error message, but in publishing time it will show a error).


Unique id in play store


Project Location
     It will automatically take the previous project path, if you want the same path no need to change it, or you can change.

Application directory

3) Then press Next button
     In this window select the minimum target SDK ,wear, TV, and Android auto.

Minimum SDK
     Here you can select the minimum required android os version.

Choose Minimum SDK target version

Wear
     This mean is this application support wearable android device or not (If yes then check or uncheck it).

Wearable android device or not

Wearable device

Android TV
     It will indicate this application is applicable for Android TV.

Android TV android studio

Android tv os

Android auto
Android auto



4) Click next in this dialog box, you can find some template, if you want any templates from there you can select otherwise select "Blank Activity".

Blank Activity in android studio new project

5) Click next and enter the activity name, layout name, title and menu resource name, you can change it or leave it and just press finish button.

Final of the new project window

 6) Click Finish. Now you can write your code here.










Friday, 5 August 2016

If you want to set the SDK path  directly you can set it to in local.properties like below

sdk.dir=D\:\\Program Files\\Android Studio\\SDK




If you want to set the NDK path  directly you can set it to in local.properties like below
ndk.dir=C\:\\android-ndk-r12b-windows-x86\\android-ndk-r12b

NDK directory set in local.properties


We can set the path by selecting folder by using the below method. After open the android studio press Ctrl+Shift+Alt+S


Select NDK SDK and JDK directly from tools




Wednesday, 27 July 2016

     Usually the identity field does not allow the user to edit, when you right click on the table and select Edit.







     But we can edit edit this column through query. Through query we can temporary on the identity insert. Remember after edit the column you should off it, if not you cannot able to edit the identity field on other tables.

Example
SET IDENTITY_INSERT Table_Name ON

INSERT Table_Name(IdentityColumnName, Col1,Col2) VALUES (54,value1,value2)

SET IDENTITY_INSERT Table_Name OFF





Tuesday, 28 June 2016

     Some situation user need to trigger the postback dynamically from client side using javascript or jQuery. In this situation you can follow this method.

Asp Button

<asp:Button ID="dmypbbtn" runat="server" OnClick="dmycall" style="display:none;" />
javascript code

document.getElementById("<%=dmypbbtn.ClientID%>").click();
jQuery Code

$("#<%=dmypbbtn.ClientID%>").trigger('Click');

     When you trigger the click function like the above format, the server side dmycall method will call with serverside postback.

Monday, 27 June 2016

     We can pass the argument to onclick serverside function using CommandArgument attribute like below.

Asp Code

   <asp:Button id="bid" CommandArgument="456" runat="server" OnClick="passvalue" />


serverside code (.cs)

    protected void passvalue(object sender, EventArgs e)

    {

        LinkButton btn = (LinkButton)(sender);

        String testval = btn.CommandArgument; //Returns 456

    }
     We can pass the arguments(values) to onclick serverside function using CommandArgument attribute. Here we send the value using the same way of single value passing, but every values are separated by comma and from serverside we can split into unique data value.

Asp Button

   <asp:Button id="bid" CommandArgument="456,Rajesh" runat="server" OnClick="passvalue" />

serverside code (.cs)

    protected void passvalues(object sender, EventArgs e)
    {
        LinkButton btn = (LinkButton)(sender);
        String fullvalue = btn.CommandArgument;   //"456,Rajesh"

        String[] args= fullvalue.Split(new char[] { ',' });
        int mark = Convert.ToInt32(args[0]);   //Returns 456
        string name = args[1];     //Returns "Rajesh"
    }

Monday, 13 June 2016

     The following animation created using pure css and html code no javascript.



Example Program:- (Editor)


Editor is Loading...

Advertisement

Thursday, 2 June 2016

     If you want to know if the dropdown change function is calling from human click change or call on dynamically change. You can use the following example.


Example Program:- (Editor)


Editor is Loading...

Advertisement

Monday, 30 May 2016

     Consider one situation I need to pass some data to sql using linq to sql, so I am created and object for dbml and send the values through it. But it show some error, we can easy to identify the error while give the value directly to the method, so we can find the data type mismatch error.



Parameter error in c#



     In the following image we are pass the value directly, so we can find the data type mismatch. Compare to the both image third variable is wrong.

     In the following image we are pass the value directly, so we can find the data type mismatch. Compare to the both image third variable is wrong.

     Usually some one checking all the radio button(checked or not) one by one and get the selected radio button value. But we can get the radio button value in a single line using jquery.

Example
asp Radio button

   <asp:RadioButtonList ID="Rbtn_ModeSetBy" runat="server">
        <asp:ListItem Value="0">All Employees</asp:ListItem>
        <asp:ListItem Value="1">Grade</asp:ListItem>
        <asp:ListItem Value="2">Job Title</asp:ListItem>
        <asp:ListItem Value="3">Employment Status</asp:ListItem>
   </asp:RadioButtonList>

jQuery Code

   var val =$('[id*="<%=Rbtn_ModeSetBy.ClientID%>"]').find('input:checked').val();

Friday, 20 May 2016

     I am a customer of hatsun curd. I brought two hutsun curd for my 1year baby, but it was defected and have some bad smell so I thought it reached the expiry date, but 5days left for expiry. So please don't brought, mainly for baby's. I saw the defect, if I not seen then? I can't think about it. I attached some screen shot below please seen it and don't brought it for your baby's.


Note:
     If any hatsun related pepole seen this post please I request you to care about this problem.