NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

Main activity

package com.example.blog;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.app.Activity;
import android.app.ListActivity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.support.constraint.ConstraintLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MainActivity extends Activity {

private RecyclerView mRecyclerView;
private ListViewAdaptor mAdapter;
private List<Data> mDataList = new ArrayList<>();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


// String[] values = new String[] { "a", "b", "c", "d", "e", "f", "g",
// "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
// "t", "u", "w", "x", "y", "z" };
//
// ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
// android.R.layout.simple_list_item_single_choice, values);
// setListAdapter(adapter);
// getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);

mAdapter = new ListViewAdaptor(mDataList);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setAdapter(mAdapter);
prepareList();
}

public void myClickHandler(View v)
{

//reset all the listView items background colours before we set the clicked one..
// ListView lvItems = getListView();
// for (int i=0; i<lvItems.getChildCount(); i++)
// {
// lvItems.getChildAt(i).setBackgroundColor(Color.BLUE);
// }


//get the row the clicked button is in
ConstraintLayout vwParentRow = (ConstraintLayout)v.getParent();

// TextView child = (TextView)vwParentRow.getChildAt(0);
Button btnChild = (Button)vwParentRow.getChildAt(3);
EditText ed = (EditText)vwParentRow.getChildAt(4);
String str = ed.getText().toString();

// btnChild.setText(child.getText());
btnChild.setText("I've been clicked!");

//https://regex101.com/r/cO8lqs/6
//https://medium.com/factory-mind/regex-tutorial-a-simple-cheatsheet-by-examples-649dc1c3f285
String number = "";
Pattern pattern = Pattern.compile("(\w)*(\+|\w)(\d)+(\D)*$");
Matcher matcher = pattern.matcher(str);
if (matcher.find())
{
System.out.println("wwww " + matcher.group(0));
number = matcher.group(0);
}

int c = Color.CYAN;

vwParentRow.setBackgroundColor(c);
vwParentRow.refreshDrawableState();

try {
Intent callIntent = new Intent(Intent.ACTION_DIAL);
callIntent.setData(Uri.parse("tel:"+number));
getApplicationContext().startActivity(callIntent);
} catch (ActivityNotFoundException activityException) {
Toast.makeText(getApplicationContext(), "call failed", Toast.LENGTH_LONG).show();
}
}
// mDataList.clear();
// Data data = new Data("Item*","Price4",R.drawable.ok);
// mDataList.add(data);
// data = new Data("Item+","Price5",R.drawable.ok);
// mDataList.add(data);

public void prepareList(){
Data data = new Data("Item1 item item item Item1 item item item Item1 item item item Item1 item item item Item1 item item itemItem1 item item item Item1 item item item","Price1",R.drawable.ok);
mDataList.add(data);
data = new Data("Item1 item item item Item1 item item item Item1 item item item Item1 item item item Item1 item item itemItem1 item item item Item1 item item item ,+++012358746","Price2",R.drawable.ok);
mDataList.add(data);
data = new Data("Item1 item item item Item1 item item item Item1 item item item Item1 item item item Item1 item item itemItem1 item item item Item1 item item item ..0178459875","Price3",R.drawable.ok);
mDataList.add(data);
data = new Data("Item1 item item item Item1 item item item Item1 item item item Item1 item item item Item1 item item itemItem1 item item item Item1 item item item","Price4",R.drawable.ok);
mDataList.add(data);
data = new Data("Item1 item item item Item1 item item item Item1 item item item Item1 item item item Item1 item item itemItem1 item item item Item1 item item item","Price5",R.drawable.ok);
mDataList.add(data);

data = new Data("Item1 item item item Item1 item item item Item1 item item item Item1 item item item Item1 item item itemItem1 item item item Item1 item item item","Price2",R.drawable.ok);
mDataList.add(data);
data = new Data("Item1 item item item Item1 item item item Item1 item item item Item1 item item item Item1 item item itemItem1 item item item Item1 item item item","Price3",R.drawable.ok);
mDataList.add(data);
data = new Data("Item1 item item item Item1 item item item Item1 item item item Item1 item item item Item1 item item itemItem1 item item item Item1 item item item","Price4",R.drawable.ok);
mDataList.add(data);
data = new Data("Item1 item item item Item1 item item item Item1 item item item Item1 item item item Item1 item item itemItem1 item item item Item1 item item item","Price5",R.drawable.ok);
mDataList.add(data);
}


// @Override
// public boolean onCreateOptionsMenu(Menu menu) {
// // getMenuInflater().inflate(R.menu.main, menu);
// return true;
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// Toast.makeText(this,
// String.valueOf(getListView().getCheckedItemCount()),
// Toast.LENGTH_LONG).show();
// Toast.makeText(this,
// "This is working",
// Toast.LENGTH_LONG).show();
// System.out.println("wwww working !!!!!!");
// return true;
// }
}

Menifest
<uses-permission android:name="android.permission.CALL_PHONE" />


list_view
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<ImageView
android:id="@+id/image"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_marginBottom="11dp"
android:src="@mipmap/ic_launcher"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/name"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/name1"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center"
android:text="name"
android:textSize="26sp"
app:layout_constraintBaseline_toBaselineOf="@+id/price"
app:layout_constraintEnd_toStartOf="@+id/price"
app:layout_constraintStart_toEndOf="@+id/image" />

<TextView
android:id="@+id/price"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginBottom="8dp"
android:gravity="center"
android:text="price"
android:textSize="26sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/BtnToClick"
app:layout_constraintStart_toEndOf="@+id/name"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/BtnToClick"
android:layout_width="101dp"
android:layout_height="80dp"
android:gravity="center"
android:onClick="myClickHandler"

android:text="Click me!"
app:layout_constraintBaseline_toBaselineOf="@+id/price"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/price"></Button>

<EditText
android:id="@+id/name"
android:layout_width="101dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="1dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:ems="10"

android:inputType="textMultiLine"
android:text="item"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/price"
app:layout_constraintStart_toStartOf="@+id/name1"
app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>


     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.