Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.helloparsing;
- import android.os.Bundle;
- import android.annotation.SuppressLint;
- import android.app.Activity;
- import android.view.*;
- import android.widget.*;
- import android.content.*;
- import org.jsoup.Jsoup;
- import org.jsoup.nodes.Document;
- import org.jsoup.select.Elements;
- public class HelloParsing extends Activity {
- Button parse;
- TextView date, bible, title, body;
- Document doc;
- Elements dates, bibles, titles, bodies;
- String tanggal, ayat, judul, isi;
- private ShareActionProvider mShareActionProvider;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_hello_parsing);
- parse = (Button)findViewById(R.id.parse);
- date = (TextView)findViewById(R.id.date);
- bible = (TextView)findViewById(R.id.bible);
- title = (TextView)findViewById(R.id.title);
- body = (TextView)findViewById(R.id.body);
- parse.setOnClickListener(new View.OnClickListener()
- {
- @Override
- public void onClick(View v)
- {
- try
- {
- doc = Jsoup.connect("http://sabda.org/publikasi/e-rh/2013/03/30/").get();
- bodies = doc.getElementsByTag("p");
- isi = bodies.text();
- body.setText(isi);
- }
- catch(Exception ex)
- {
- Toast.makeText(getApplicationContext(), "Failed \n" + ex, Toast.LENGTH_LONG).show();
- }
- }
- });
- }
- @SuppressLint("NewApi")
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.hello_parsing, menu);
- MenuItem item = menu.findItem(R.id.menu_item_share);
- mShareActionProvider = (ShareActionProvider)item.getActionProvider();
- return true;
- }
- @SuppressWarnings("unused")
- private void setShareIntent(Intent shareIntent)
- {
- if(mShareActionProvider != null)
- {
- mShareActionProvider.setShareIntent(shareIntent);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment