Twitter Facebook Delicious Digg Stumbleupon Favorites More

Sunday, 11 February 2018

calories counter android app

1) 
Share:

Thursday, 1 February 2018

Destination app

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    tools:context="com.example.viraj.destiniapp.MainActivity"
    android:background="@drawable/background"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    >


    <TextView
        android:id="@+id/storyTextView"
        android:text="@string/T1_Story"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:textSize="24sp"
        android:textColor="#ffffffff"
        />

    <Button
        android:id="@+id/buttonTop"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/T1_Ans1"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="61dp"
        android:background="#e74c3c"
        android:textColor="#ecf0f1"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:textSize="15sp"
        />

    <Button
        android:id="@+id/buttonBottom"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/T1_Ans2"
        android:layout_alignParentBottom="true"
        android:layout_alignLeft="@+id/buttonTop"
        android:layout_alignStart="@+id/buttonTop"
        android:layout_alignRight="@+id/buttonTop"
        android:layout_alignEnd="@+id/buttonTop"
        android:background="#3498db"
        android:textColor="#ecf0f1"
        android:textSize="15sp"/>

</RelativeLayout>

MAINACTIVITY.JAVA

package com.example.viraj.destiniapp;

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 AppCompatActivity {
    // TODO: Steps 4 & 8 - Declare member variables here:
    private TextView mstoryTextView;
    private Button mTopButton, mBottomButton;
    private int nStoryIndex = 1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
        // TODO: Step 5 - Wire up the 3 views from the layout to the member variables:
        mstoryTextView = findViewById(R.id.storyTextView);
        mTopButton = findViewById(R.id.buttonTop);
        mBottomButton = findViewById(R.id.buttonBottom);


        // TODO: Steps 6, 7, & 9 - Set a listener on the top button:

        mTopButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
               if (nStoryIndex==1 || nStoryIndex==2){
                mstoryTextView.setText(R.string.T3_Story);
                mTopButton.setText(R.string.T3_Ans1);
                mBottomButton.setText(R.string.T3_Ans2);
                   nStoryIndex = 3;
            }else if (nStoryIndex==3){
                   mstoryTextView.setText(R.string.T6_End);
                   mTopButton.setVisibility(view.GONE);
                   mBottomButton.setVisibility(view.GONE);
               }
              }
        });


        // TODO: Steps 6, 7, & 9 - Set a listener on the bottom button:
        mBottomButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (nStoryIndex == 1) {
                    mstoryTextView.setText(R.string.T2_Story);
                    mTopButton.setText(R.string.T2_Ans1);
                    mBottomButton.setText(R.string.T2_Ans2);
                    nStoryIndex = 2;
                } else if (nStoryIndex == 2) {
                    mstoryTextView.setText(R.string.T4_End);
                    mTopButton.setVisibility(view.GONE);
                    mBottomButton.setVisibility(view.GONE);
                }
                else  {
                    mstoryTextView.setText(R.string.T5_End);
                    mTopButton.setVisibility(view.GONE);
                    mBottomButton.setVisibility(view.GONE);
                }
            }
        });
    }
}

dimension xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- Default screen margins, per the Android Design guidelines. -->
    <dimen name="activity_horizontal_margin">16dp</dimen>
    <dimen name="activity_vertical_margin">16dp</dimen>
</resources>

dimension 8210 dp xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- Example customization of dimensions originally defined in res/values/dimens.xml
         (such as screen margins) for screens with more than 820dp of available width. This
         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
    <dimen name="activity_horizontal_margin">64dp</dimen>
</resources>

string.xml

<resources>
    <string name="app_name">Destini</string>

    <string name="T1_Story">Your car has blown a tire on a winding road in the middle of nowhere with no cell phone reception. You decide to hitchhike. A rusty pickup truck rumbles to a stop next to you. A man with a wide brimmed hat with soulless eyes opens the passenger door for you and asks: \"Need a ride, boy?\". </string>
    <string name="T1_Ans1">I\'ll hop in. Thanks for the help! </string>
    <string name="T1_Ans2">Better ask him if he\'s a murderer first. </string>


    <string name="T2_Story">He nods slowly, unphased by the question.</string>
    <string name="T2_Ans1">At least he\'s honest. I\'ll climb in.</string>
    <string name="T2_Ans2">Wait, I know how to change a tire.</string>


    <string name="T3_Story">As you begin to drive, the stranger starts talking about his relationship with his mother. He gets angrier and angrier by the minute. He asks you to open the glovebox. Inside you find a bloody knife, two severed fingers, and a cassette tape of Elton John. He reaches for the glove box.</string>
    <string name="T3_Ans1">I love Elton John! Hand him the cassette tape.</string>
    <string name="T3_Ans2">It\'s him or me! You take the knife and stab him.</string>


    <string name="T4_End">What? Such a cop out! Did you know traffic accidents are the second leading cause of accidental death for most adult age groups?</string>
    <string name="T5_End">As you smash through the guardrail and careen towards the jagged rocks below you reflect on the dubious wisdom of stabbing someone while they are driving a car you are in.</string>
    <string name="T6_End">You bond with the murderer while crooning verses of "Can you feel the love tonight". He drops you off at the next town. Before you go he asks you if you know any good places to dump bodies. You reply: \"Try the pier.\"</string>

</resources>
Share:

Search This Blog

Popular Posts

Pages

how to make crores from 1 lakh in stock markets in 1 year

how to make crores from 1 lakh in stock markets in 1 year

Blogger Tutorials

Blogger Templates

Sample Text

Copyright © ANDROID TUTORIAL CODE | Powered by Blogger
Design by SimpleWpThemes | Blogger Theme by NewBloggerThemes.com & Distributed By Protemplateslab