App Manifest
App Manifest
App Manifest
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<application
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".SRCWComputerScienceQuiz"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
android:value="com.example.bhavin.srcwcomputersciencequiz.SRCWComputerScienceQui
z" />
</activity>
<activity
android:name=".CUnitOne"
android:label="@string/title_activity_cunit_one"
android:parentActivityName=".C"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.bhavin.srcwcomputersciencequiz.C" />
</activity>
</application>
</manifest>
App-COLOUR:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#d201fc</color>
<color name="colorPrimaryDark">#d201fc</color>
<color name="colorAccent">#d201fc</color>
</resources>
Gradle-BUILD GRADLE:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.bhavin.srcwcomputersciencequiz"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//testCompile 'junit:junit:4.12' Commented [B1]: // will not be there
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services-ads:7.8.0'
}
App-MENU:
<menu 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"
tools:context="com.example.bhavin.srcwcomputersciencequiz.SRCWComputerScienceQuiz
">
<item
android:id="@+id/action_share"
android:orderInCategory="100"
android:title="Share"
app:showAsAction="always"
app:actionProviderClass="android.support.v7.widget.ShareActionProvider"/>
/>
</menu>
App- CONTENT :
<?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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="#fdfdfd"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.bhavin.srcwcomputersciencequiz.SRCWComputerScienceQuiz
"
tools:showIn="@layout/activity_srcwcomputer_science_quiz">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/banner"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#d201fc"
android:layout_marginTop="130dp"
android:textSize="20dp"
android:textAlignment="center"
android:text="Accredited by NAAC,An 9001:2008 Certified Institution Affiliated
to Bharathiar University \nCoimbatore-641 044"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="230dp"
android:text="Select the subject to start quiz"
android:textColor="#d201fc"
android:textSize="18dp"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="250dp"
android:layout_marginBottom="55dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:id="@+id/button16"
android:onClick="ad"
android:background="#d201fc"
android:text="ADIS"
android:textSize="25dp"
android:textColor="#fdfdfd"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
App-JAVA:
package com.example.bhavin.srcwcomputersciencequiz;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.ShareActionProvider;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_srcwcomputer_science_quiz);
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
@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_srcwcomputer_science_quiz, menu);
MenuItem item = (MenuItem) menu.findItem(R.id.action_share);
ShareActionProvider shareAction = (ShareActionProvider)
MenuItemCompat.getActionProvider(item);
Intent shareIntent = new Intent(Intent.ACTION_SEND)
.putExtra(Intent.EXTRA_TEXT, "Android Application for Quiz in Computer
Science " + "http://play.google.com/store/apps/details?id=" + getPackageName())
.putExtra(Intent.EXTRA_SUBJECT, "Quiz on Computer Science Subjects
exclusively build on the basis of Sri Ramakrishna College of ARts and Science For Wormen
Syllubus")
.setType("text/plain");
shareAction.setShareIntent(shareIntent);
return true;
}
public void ad(View view) {
String button_ad;
button_ad = ((Button) view).getText().toString();
if (button_ad.equals("ADIS")) {
Intent intent = new Intent(this, ADIS.class);
startActivity(intent);
}
}
}
C CONTENT:
<?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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="#fdfdfd"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.bhavin.srcwcomputersciencequiz.CUnitOne"
tools:showIn="@layout/activity_cunit_one">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="1. The term computer is derived from the word"
android:textColor="#d201fc"
android:textSize="20dp"
/>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/radiogroup1"
android:layout_marginTop="10dp">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/r1"
android:textSize="18dp"
android:textColor="#d201fc"
android:text=" Compute"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/r2"
android:textSize="18dp"
android:textColor="#d201fc"
android:text=" Compete "
/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/r3"
android:textSize="18dp"
android:textColor="#d201fc"
android:text=" Calculate "
/>
</RadioGroup>
</LinearLayout>
</ScrollView>
</RelativeLayout>
App- C JAVA:
package com.example.bhavin.srcwcomputersciencequiz;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.graphics.Color;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
}
});
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
}
Database
ADD TO CART
TOTAL AMOUNT
SEND THROUGH EMAIL
package com.example.logeshwari.medicinalplantsanditsuses;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
@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);
}
}
DATABASE CODING
package com.example.logeshwari.medicinalplantsanditsuses;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.text.TextWatcher;
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
sqLiteDatabase.execSQL("create table " + TABLE_NAME + "(ID INTEGER
PRIMARY KEY AUTOINCREMENT, ITEM_NAME TEXT, PRICE INTEGER)");
sqLiteDatabase.execSQL("create table " + TABLE_NAME_2 + "(ID INTEGER
PRIMARY KEY AUTOINCREMENT, ITEM_NAME TEXT, PRICE INTEGER,
QUANTITY TEXT)");
String[] items = {
"Aloevera ", "21",
"Amaltas", "24",
"Amla", "22",
"Ampalaya", "28",
"Vidarikanda", "25"
};
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME_2);
onCreate(sqLiteDatabase);
}
PRODUCT
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// Get the data item for this position
Product product = getItem(position);
// Populate the data into the template view using the data object
t_id.setText(product.id);
t_name.setText(product.name);
t_price.setText("Rs."+product.price);
CART
package com.example.logeshwari.medicinalplantsanditsuses;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.InputMismatchException;
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// Get the data item for this position
CartItem cartItem = getItem(position);
// Populate the data into the template view using the data object
t_id.setText(cartItem.id);
t_name.setText(cartItem.name);
t_price.setText(cartItem.quantity+"/"+cartItem.price);
Integer amount = Integer.parseInt(cartItem.price.toString())*
Integer.parseInt(cartItem.quantity.toString());
t_amount.setText(amount.toString());
<TextView
android:layout_width="70dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:id="@+id/item_id"
android:text="1"
android:gravity="center"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"/>
<TextView
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_toRightOf="@id/item_id"
android:id="@+id/item_name"
android:text="Avacada"
android:gravity="center"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"/>
<TextView
android:layout_width="120dp"
android:layout_height="match_parent"
android:layout_toRightOf="@+id/item_name"
android:id="@+id/item_price"
android:text="Rs.15"
android:gravity="center"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"/>
</RelativeLayout>
CART ROW
<TextView
android:layout_width="60dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:id="@+id/cart_item_id"
android:text="S.no"
android:gravity="center"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"/>
<TextView
android:layout_width="120dp"
android:layout_height="50dp"
android:layout_toRightOf="@id/cart_item_id"
android:id="@+id/cart_item_name"
android:text="Name"
android:gravity="center"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"/>
<TextView
android:layout_width="90dp"
android:layout_height="50dp"
android:layout_toRightOf="@+id/cart_item_name"
android:id="@+id/cart_item_price"
android:text="Qty/Price"
android:gravity="center"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"/>
<TextView
android:layout_width="90dp"
android:layout_height="50dp"
android:layout_toRightOf="@+id/cart_item_price"
android:id="@+id/total_amount"
android:text="Amount"
android:gravity="center"
</RelativeLayout>