Complete Solution for every problem | Mobile Technology | Web Technology | Software | Mobile Apps | Scripts | Tricks | Latest Technology | Wordpress Plugins


Line Post
Showing posts with label freestuff. Show all posts
Showing posts with label freestuff. Show all posts

10 October, 2015

Recycler view and Card View in Andorid Development



Recyclerview is more advanced and flexible version of Listview added in Lollipop. It also Support in lower API of Android. This widget is a container for displaying large data sets that can be scrolled very efficiently by maintaining a limited number of views. Use the RecyclerView widget when you have data collections whose elements change at runtime based on user action or network events.

Application Development
Recycler view

The RecyclerView class simplifies the display and handling of large data sets by providing:
·         Layout managers for positioning items
·         Default animations for common item operations, such as removal or addition of items

To  add RecyclerView in your Project. you have to add Library of Recyclerview.

If you are using Android Studio and you are Supporting lower APIs,  You just need to add Gradle URL into your Module's Gradle file.

dependencies {

compile 'com.android.support:recyclerview-v7:23.0.1'

}

Once you sync  gradle lib from google will be downloaded into your project and you can use it.

Add RecyclerView into your activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
   
xmlns:tools="http://schemas.android.com/tools"
   
android:layout_width="match_parent"
   
android:layout_height="match_parent"
   
tools:context=".MainActivity">

    <android.support.v7.widget.RecyclerView
       
android:id="@+id/recycler_view"
       
android:layout_width="match_parent"
       
android:layout_height="match_parent"
       
android:scrollbars="vertical" />
</LinearLayout>

Now you have added RecyclerView widget into your layout file, Obtain a handle to the object and connect it to layout manager and attach an adapter to show data.

public class MainActivity extends AppCompatActivity {



    ArrayList<String> arrayList = new ArrayList<>();



    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);



        for (int i = 0; i < 15; i++) {

            arrayList.add(String.valueOf(i));

        }



        RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);



        /**

         *To Show RecyclerView as a List of data, LayoutManager is important to set.

         *  For ListView : LinearLayoutManager is used.

         *  For GridView : GridLayoutManager is used.

         *  For Staggered GridView: StaggeredGridLayoutManager is used

         */

        LinearLayoutManager manager = new LinearLayoutManager(MainActivity.this);

        recyclerView.setLayoutManager(manager);



        MyRecyclerViewAdapter myRecyclerViewAdapter = new MyRecyclerViewAdapter(MainActivity.this, arrayList);

        recyclerView.setAdapter(myRecyclerViewAdapter);

    }



    @Override

    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.

        getMenuInflater().inflate(R.menu.menu_main, menu);

        return true;

    }



    @Override

    public boolean onOptionsItemSelected(MenuItem item) {

        // Handle action bar item clicks here. The action bar will

        // automatically handle clicks on the Home/Up button, so long

        // as you specify a parent activity in AndroidManifest.xml.

        int id = item.getItemId();



        //noinspection SimplifiableIfStatement

        if (id == R.id.action_settings) {

            return true;

        }



        return super.onOptionsItemSelected(item);

    }

}

RecyclerView Adpter :

public class MyRecyclerViewAdapter extends RecyclerView.Adapter<MyRecyclerViewAdapter.ViewHolder> {



    Context context;

    ArrayList<String> strings;



    /**

     * public Constructor

     */

    public MyRecyclerViewAdapter(Context context, ArrayList<String> arrayList) {



        this.context = context;

        this.strings = arrayList;

    }



    @Override

    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_layout, parent, false);

        return new ViewHolder(view);

    }



    @Override

    public void onBindViewHolder(ViewHolder holder, int position) {



        holder.textView.setTag(position);

        holder.cardView.setTag(position);



        holder.textView.setText(strings.get(position));



        if (position % 2 == 0) {

            holder.cardView.setBackgroundColor(context.getResources().getColor(R.color.colorzero, null));

        } else {

            holder.cardView.setBackgroundColor(context.getResources().getColor(R.color.colorone, null));

        }



    }



    @Override

    public int getItemCount() {

        return strings.size();

    }



    public class ViewHolder extends RecyclerView.ViewHolder {



        TextView textView;

        CardView cardView;



        public ViewHolder(View itemView) {

            super(itemView);

            textView = (TextView) itemView.findViewById(R.id.textview);

            cardView = (CardView) itemView.findViewById(R.id.card_view);

        }

    }

}

CardView :

CardView is a extension of FrameLayout which lets you show data into card. It can have Shadows and Corners.

To show shadow use "cardElevation" attribute. In lollipop devices cardview uses real elevation and dynamic shadows.

Use these properties to customize the appearance of the CardView widget:

·         To set the corner radius in your layouts, use the card_view:cardCornerRadius attribute.
·         To set the corner radius in your code, use the CardView.setRadius method.
·         To set the background color of a card, use the card_view:cardBackgroundColor attribute.  

If you are using Android Studio and you are Supporting lower APIs,  You just need to add Gradle URL into your Module's Gradle file.

dependencies { compile 'com.android.support:cardview-v7:23.0.1'}





<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:gravity="center"

    android:orientation="vertical">



    <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"

        android:id="@+id/card_view"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_gravity="center_vertical"

        android:layout_margin="10dp"

        android:foregroundGravity="center"

        android:minHeight="50dp"

        card_view:cardCornerRadius="4dp"

        card_view:cardElevation="3dp">



        <TextView

            android:id="@+id/textview"

            android:layout_width="match_parent"

            android:layout_height="match_parent"

            android:layout_gravity="center_vertical"

            android:text="TextView"

            android:textColor="#000"

            android:textSize="25sp" />

    </android.support.v7.widget.CardView>

</LinearLayout>


To Check Full code please Go to Below Link.
Read more ...

25 November, 2014

How to secure internet from hackers

Want FAST, SECURE and PRIVATE browsing....

Use this

"Disconnect.me"
It is browser extension helps users monitor and block more than 2,000 websites from collecting their data online.

Disconnect.me was founded by an ex-Googler to put users in control of their browsing history. disconnect me secure you from third party ads, other popup windows and much more 

Features :

  • Visualize Trackers 
  • Encrypted Internet
  • Safe Browsing 
  • Location Control
  • Anonymous Search

Secure your Internet from hackers  

 

Here is the link  : Click Here

Read more ...

24 November, 2014

How to format usb flash drive using MS-DOS

Hey Friends today i will teach how to format usb flash drive using MS-DOS. Many times we need to format our usb drives, people find it difficult so today reading this article you will be able to format you usb very easily,lets see the steps.

1) Click Start > Run... and type cmd in the box then Click OK

2) The command prompt window appears.

3) Type the following command:

format X:

Note: Replace "X:" with the letter of your USB Flash Drive.
You can use "diskpart" to list all drive letters.

4) If you want to format it as FAT32 then type:

format X: /FS:FAT32

5) After typing one of the above commands, press Enter

6) When it asks for pressing Enter again, just press it to confirm.

7) It will prompt you to enter a name for the drive, write it and hit Enter

So by reading this article i hope you will be now easily able to format your USB flash dirve.

Read more ...

22 November, 2014

25 Useful Ubuntu Shortcuts To Make your Linux Easier


Switch Workspaces in Ubuntu (win + E)
1. Win+E - Shows all workspaces in a nifty way and lets you switch between workspaces easily.
2. Alt+Ctrl+Left/Right Arrow – Move to Workspace on Left/Right
3. Alt+Ctrl+Shift+Left/Right Arrow – Move current window to another workspace
4. Alt + Shift+ Up Arrow – This initiates a cool looking window switcher interface with which you can switch between windows using Arrow keys while holding Alt + Shift

Ubuntu Window Switcher (Alt + Shift+ Up Arrow)
5. Alt+F9/F10 – Minimize/ Maximize current window
6. Alt+F5 – UnMaximizes Current Window
7. Alt+F7 – This shortcut activates the move window option that lets you move current window using arrow keys. You can even move window to other workspace, try moving it to extreme right.
8. Alt+F8 – Resize current window with arrow keys
9. Ctrl + Alt + D – Show Desktop/ Restore open windows if show desktop used earlier
10. Alt+Shift+Tab – Switch Windows in Reverse Direction as done using Alt+Tab

Nautilus

11. Shift+Ctrl+N – Create New Folder, Very useful shortcut
12. Alt + Enter – Show properties of a selected file/folder without requiring to right click on it and select Properties.
13. Ctrl + 1/2 – Change folder view to icon/list.
14. Ctrl + W – close current Nautilus Window
15. Ctrl + Shift + W – close all open Nautilus Windows
16. Ctrl+T – Open a new tab in Nautilus
17. Alt + Up/Down Arrow – Move to Parent Folder/ Selected folder
18. Alt + Left/Right Arrow – Move Back/forward in Nautilus
19. Alt + Home – Move directly to your Home Folder
20. F9 – Toggle display of Nautilus Sidepane
21. Ctrl + H – Toggle Display of hidden files and folders

Miscellaneous

22. Ctrl + Alt + L - Quick shortcut to Lock Screen if you need to be away from your desktop for few moments and don’t want others to see your desktop.
23. Alt + F1 – Open Applications Menu
24. Alt + F2 – Open the Run Application dialog Box
25. Win + Mousewheel – Zoom in / Zoom out Desktop. This one’s pretty useful if  you are having a wireless keyboard/mouse.
I hope these shortcuts will make your life easier doing routine repetitive tasks and make you more productive using your Ubuntu System.
If you know of some other useful Ubuntu shortcuts, feel free to share them in comments below.
Read more ...

14 April, 2014

Best Alternative of well known commercial software to opensource

I sometimes why we pay for a software that has an equally good alternative. I guess the advert spend is working in their favor, you can get a free equivalent of almost all the software’s available. For example Linux OS is free, Windows is not, let’s get down to business.

Antivirus – Norton/Kaspersky vs. Avast!/AVG

  • Now a days people think that paid antivirus software is more effective than freeware, but it scenario is different.
  • Free ware Antivirus also have same features and capability to remove viruses, worms and other malicious program. So avast, avg and many other antivirus software provides good features. 

Office Suite – Microsoft Office vs. LibreOffice

Libre Office
  • The most alternative of commonly used software is libre office. Libre office having the same features which is provided by microsoft.

  •  The standard formats used worldwide are Microsoft Office formats; they offer guaranteed compatibility.

Image Editing – Adobe Photoshop vs. GIMP  

 
GIMP

  •  Gimp is the best tool to edit photo like photoshop. It includes almost all features of 
    photoshop.
  •  Plugins can be added to Gimp to make up for the missing features.

 

Vector Editing – Adobe Illustrator vs. Inkscape

 
  • You can edit SVG source directly.
  • Single Click Paint bucket.
  • Easy to move/rotate/transform
  • Short keys available 
More free stuff will be available on starline technolab
Thanks :) :)

Read more ...

06 February, 2014

PHP scripts for export data into csv file

Here i will explain how to export data into csv file in php

Follow the step which is given below

STEP - I 

     FILE : exortcontact.php

           <?PHP
                 include_once('ExportToExcel.class.php');
                 include_once("../config/connection.php");
                 $exp=new ExportToExcel();
                 $qry="select * from abc";
                 $exp->exportWithQuery($qry,"ExportData.xls",$con);
           ?>
                 
 NOTE : abc is data table which you convert into csv

STEP - II

   FILE : 
          
           <?php

               class ExportToExcel
             {  
                  function exportWithPage($php_page,$excel_file_name)  
                     {  
                           $this->setHeader($excel_file_name);   require_once "$php_page";   
                      }    

                function setHeader($excel_file_name)  
                   {   
                        header("Content-type: application/octet-stream");  
                        header("Content-Disposition: attachment;filename=$excel_file_name");  
                        header("Pragma: no-cache");  
                        header("Expires: 0");    
                    }    

                function exportWithQuery($qry,$excel_file_name,$conn)  
                  {  
                       $tmprst=mysql_query($qry,$conn);  
                        $header="<center><table border=1px><th>ID</th><th>NAME</th><th>EMAIL</th>                                     <th>PHONE</th><th>CITY</th><th>STATE</th><th>KNOW FROM</th>                                             <th>NEWSPAPER NAME</th><th>DATE</th>";  
                        $num_field=mysql_num_fields($tmprst);  
                        $body="";  
                        while($row=mysql_fetch_array($tmprst,MYSQL_BOTH))  
                        {  
                            $body.="<tr>";   
                            for($i=0;$i<$num_field;$i++)   
                            {    
                               $body.="<td>".$row[$i]."</td>";  
                            }   
                            $body.="</tr>";   
                         }  
                        $this->setHeader($excel_file_name);  
                        echo $header.$body."</table>";  
                   }
         } 
         ?>

NOTE : $header use for the formatting your data which you want to convert 

Keep visiting and enjoy coding 



Read more ...

Comments

Designed By