Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package yo.share;
- import android.content.Intent;
- import android.os.Bundle;
- import android.support.design.widget.FloatingActionButton;
- import android.support.v7.app.AppCompatActivity;
- import android.support.v7.widget.Toolbar;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.view.View;
- import android.widget.Button;
- import android.widget.ImageView;
- import android.widget.Toast;
- public class MainActivity extends AppCompatActivity {
- Button button;
- Button Click = (Button) findViewById(R.id.button);
- String result ="";
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- ImageView Imageview = (ImageView) findViewById(R.id.imageView);
- setSupportActionBar(toolbar);
- FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
- fab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- //create the send intent
- Intent shareIntent =
- new Intent(android.content.Intent.ACTION_SEND);
- //set the type
- shareIntent.setType("text/plain");
- //add a subject
- shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
- "Insert Subject Here");
- //build the body of the message to be shared
- String shareMessage = "Insert message body here.";
- //add the message
- shareIntent.putExtra(android.content.Intent.EXTRA_TEXT,
- shareMessage);
- //start the chooser for sharing
- startActivity(Intent.createChooser(shareIntent, getResources().getString(R.string.FinalString)));
- }
- });
- }
- public class Program {
- public void main(String[] args) {
- int value1 = 300;
- double value2 = 3.14;
- short value3 = 5;
- char value4 = 'A';
- // Create StringBuilder and add four values to it.
- final StringBuilder builder = new StringBuilder();
- builder.append(value2).append("\n");
- builder.append(value3).append("\n");
- builder.append(value4);
- // Display results.
- String result = builder.toString();
- System.out.println(result);
- }
- public void onClick(View v) {
- Imageview.setOnClickListener(new View.OnClickListener() {
- builder.append(value1).result.append("\n");
- }
- }
- }
- @Override
- public void onClick(View v) {
- if (ImageView.isChecked() == true) {
- result.add("4");
- }
- }
- @Override
- public void onClick(View V){
- Toast.makeText(getApplicationContext(),result ,Toast.LENGTH_SHORT).show();
- }
- 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);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment