Skip to content

Instantly share code, notes, and snippets.

View markojerkic's full-sized avatar

Marko Jerkić markojerkic

View GitHub Profile
<?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:orientation="vertical"
android:id="@+id/activity_main"
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"
@markojerkic
markojerkic / button.xml
Last active April 1, 2017 14:34
Add a button
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button"
android:text="Hi!"/>
@markojerkic
markojerkic / Button.java
Created April 1, 2017 14:37
Java Button
package com.markojerkic.notification;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
@markojerkic
markojerkic / OnClick.java
Created April 1, 2017 14:39
onClickListener
mButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//we'll be adding some code in here
}
});
@markojerkic
markojerkic / ButtonAction.java
Created April 1, 2017 15:26
The final look at the simple notification app
public void sendNotification() {
//builds the basic notification
NotificationCompat.Builder mNotification =
(NotificationCompat.Builder) new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_info_outline_white_24px)
.setContentTitle("First Notificaion")
.setContentText("Hi!");
//sets the sound, vibration and other things to
@markojerkic
markojerkic / activity_main.xml
Created April 8, 2017 20:17
Basic LinearLayout
<?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:id="@+id/activity_main"
android:orientation="vertical"
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"
<ViewSwitcher
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ViewSwitcher>
@markojerkic
markojerkic / activity_main.xml
Last active April 8, 2017 20:34
ViewSwitcher
<?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:id="@+id/activity_main"
android:orientation="vertical"
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"
switchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(viewSwitcher.getCurrentView() == ratingBar) {
viewSwitcher.showNext();//if the current view is the RatingBar, then show
} //the next one, which is the TextView
else {
viewSwitcher.showPrevious();
}
}
@markojerkic
markojerkic / MainActivity.java
Created April 9, 2017 08:37
Setting up the RatingBar
package com.markojerkic.viewswitch;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RatingBar;
import android.widget.TextView;
import android.widget.ViewSwitcher;