Skip to content

Instantly share code, notes, and snippets.

View Nyame123's full-sized avatar

Nyame Bismark Nyame123

View GitHub Profile
@Nyame123
Nyame123 / scene_layout.xml
Created November 17, 2020 11:03
Create second scene from the xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scene_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:src="@drawable/ecomlogo1"
android:id="@+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@Nyame123
Nyame123 / first_scene.xml
Last active November 17, 2020 11:04
Create first scene
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scene_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:src="@drawable/ecomlogo1"
android:id="@+id/logo"
android:layout_width="80dp"
android:layout_height="80dp"
@Nyame123
Nyame123 / transitionEx.java
Created November 17, 2020 11:16
Create transition example
package com.bisapp.android_animations;
import android.os.Bundle;
import android.transition.ChangeBounds;
import android.transition.Fade;
import android.transition.Scene;
import android.transition.Transition;
import android.transition.TransitionManager;
import android.transition.TransitionSet;
import android.view.LayoutInflater;
@Nyame123
Nyame123 / firstActivity.java
Created November 18, 2020 20:12
Referencing views
public void onViewCreated(@NonNull final View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
logo = view.findViewById(R.id.logo);
textView = view.findViewById(R.id.text_view);
sceneRoot.setOnClickListener(new View.OnClickListener() {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void onClick(View v) {
@Nyame123
Nyame123 / second_layout.xml
Last active November 18, 2020 20:21
Second activitiy layout
//second_layout.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scene_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:src="@drawable/ecomlogo1"
android:id="@+id/logo"
@Nyame123
Nyame123 / first_layout.xml
Last active November 18, 2020 22:06
first layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/master_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/goBtn"
android:layout_width="wrap_content"
private void queryWordData() {
// A "projection" defines the columns that will be returned for each row
String[] projections = {
UserDictionary.Words._ID, // A contract class constant for _ID column name
UserDictionary.Words.WORD, // A contract class constant for WORD column name
UserDictionary.Words.APP_ID, // A contract class constant for APP_ID column name
UserDictionary.Words.LOCALE // A contract class constant for LOCALE column name
};
//word to query from the UI
private void insertWordData(){
// Defines an object to contain the new values to insert
ContentValues contentValues = new ContentValues();
contentValues.put(UserDictionary.Words.APP_ID, UUID.randomUUID().toString());
contentValues.put(UserDictionary.Words.WORD,"new Word");
contentValues.put(UserDictionary.Words.LOCALE, Locale.getDefault().toString());
contentValues.put(UserDictionary.Words.FREQUENCY, "8");
Uri newUri = getContentResolver().insert(
UserDictionary.Words.CONTENT_URI, // the user dictionary content URI
private void updateWordData() {
// Defines an object to contain the new values to insert
ContentValues updateValues = new ContentValues();
// Defines selection criteria for the rows you want to update
String selectionClause = UserDictionary.Words.LOCALE + " LIKE ?";
String[] selectionArgs = {"en_%"};
// Defines a variable to contain the number of updated rows
int rowsUpdated = 0;
private void deleteWordData() {
// Defines selection criteria for the rows you want to delete
String selectionClause = UserDictionary.Words.APP_ID + " LIKE ?";
String[] selectionArgs = {"user"};
// Defines a variable to contain the number of rows deleted
int rowsDeleted = 0;
// Deletes the words that match the selection criteria