diff --git a/samples/ApiDemos/AndroidManifest.xml b/samples/ApiDemos/AndroidManifest.xml index 6b7dd7a28..371f6236b 100644 --- a/samples/ApiDemos/AndroidManifest.xml +++ b/samples/ApiDemos/AndroidManifest.xml @@ -209,7 +209,7 @@ - + @@ -223,6 +223,15 @@ + + + + + + + + + diff --git a/samples/ApiDemos/res/layout-land/fragment_layout.xml b/samples/ApiDemos/res/layout-land/fragment_layout.xml new file mode 100644 index 000000000..24629e9df --- /dev/null +++ b/samples/ApiDemos/res/layout-land/fragment_layout.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/samples/ApiDemos/res/layout/fragment_anim.xml b/samples/ApiDemos/res/layout/fragment_anim.xml new file mode 100644 index 000000000..8bec89452 --- /dev/null +++ b/samples/ApiDemos/res/layout/fragment_anim.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/ApiDemos/res/layout/fragment_layout.xml b/samples/ApiDemos/res/layout/fragment_layout.xml index 99781777b..e7704ff47 100644 --- a/samples/ApiDemos/res/layout/fragment_layout.xml +++ b/samples/ApiDemos/res/layout/fragment_layout.xml @@ -14,21 +14,13 @@ limitations under the License. --> - + - - - - - - - + + diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml index a816b1534..25f1bf926 100644 --- a/samples/ApiDemos/res/values/strings.xml +++ b/samples/ApiDemos/res/values/strings.xml @@ -83,11 +83,13 @@ Enter the text that will be used by the main activity. Press back to cancel. Apply - App/Fragment/Stack + App/Fragment/Stack Next App/Fragment/Layout + App/Fragment/Anim + App/Fragment/Retain Instance Current progress of retained fragment; restarts if fragment is re-created. diff --git a/samples/ApiDemos/src/com/example/android/apis/Shakespeare.java b/samples/ApiDemos/src/com/example/android/apis/Shakespeare.java new file mode 100644 index 000000000..481df4b8e --- /dev/null +++ b/samples/ApiDemos/src/com/example/android/apis/Shakespeare.java @@ -0,0 +1,223 @@ +package com.example.android.apis; + +public final class Shakespeare { + /** + * Our data, part 1. + */ + public static final String[] TITLES = + { + "Henry IV (1)", + "Henry V", + "Henry VIII", + "Richard II", + "Richard III", + "Merchant of Venice", + "Othello", + "King Lear" + }; + + /** + * Our data, part 2. + */ + public static final String[] DIALOGUE = + { + "So shaken as we are, so wan with care," + + "Find we a time for frighted peace to pant," + + "And breathe short-winded accents of new broils" + + "To be commenced in strands afar remote." + + "No more the thirsty entrance of this soil" + + "Shall daub her lips with her own children's blood;" + + "Nor more shall trenching war channel her fields," + + "Nor bruise her flowerets with the armed hoofs" + + "Of hostile paces: those opposed eyes," + + "Which, like the meteors of a troubled heaven," + + "All of one nature, of one substance bred," + + "Did lately meet in the intestine shock" + + "And furious close of civil butchery" + + "Shall now, in mutual well-beseeming ranks," + + "March all one way and be no more opposed" + + "Against acquaintance, kindred and allies:" + + "The edge of war, like an ill-sheathed knife," + + "No more shall cut his master. Therefore, friends," + + "As far as to the sepulchre of Christ," + + "Whose soldier now, under whose blessed cross" + + "We are impressed and engaged to fight," + + "Forthwith a power of English shall we levy;" + + "Whose arms were moulded in their mothers' womb" + + "To chase these pagans in those holy fields" + + "Over whose acres walk'd those blessed feet" + + "Which fourteen hundred years ago were nail'd" + + "For our advantage on the bitter cross." + + "But this our purpose now is twelve month old," + + "And bootless 'tis to tell you we will go:" + + "Therefore we meet not now. Then let me hear" + + "Of you, my gentle cousin Westmoreland," + + "What yesternight our council did decree" + + "In forwarding this dear expedience.", + + "Hear him but reason in divinity," + + "And all-admiring with an inward wish" + + "You would desire the king were made a prelate:" + + "Hear him debate of commonwealth affairs," + + "You would say it hath been all in all his study:" + + "List his discourse of war, and you shall hear" + + "A fearful battle render'd you in music:" + + "Turn him to any cause of policy," + + "The Gordian knot of it he will unloose," + + "Familiar as his garter: that, when he speaks," + + "The air, a charter'd libertine, is still," + + "And the mute wonder lurketh in men's ears," + + "To steal his sweet and honey'd sentences;" + + "So that the art and practic part of life" + + "Must be the mistress to this theoric:" + + "Which is a wonder how his grace should glean it," + + "Since his addiction was to courses vain," + + "His companies unletter'd, rude and shallow," + + "His hours fill'd up with riots, banquets, sports," + + "And never noted in him any study," + + "Any retirement, any sequestration" + + "From open haunts and popularity.", + + "I come no more to make you laugh: things now," + + "That bear a weighty and a serious brow," + + "Sad, high, and working, full of state and woe," + + "Such noble scenes as draw the eye to flow," + + "We now present. Those that can pity, here" + + "May, if they think it well, let fall a tear;" + + "The subject will deserve it. Such as give" + + "Their money out of hope they may believe," + + "May here find truth too. Those that come to see" + + "Only a show or two, and so agree" + + "The play may pass, if they be still and willing," + + "I'll undertake may see away their shilling" + + "Richly in two short hours. Only they" + + "That come to hear a merry bawdy play," + + "A noise of targets, or to see a fellow" + + "In a long motley coat guarded with yellow," + + "Will be deceived; for, gentle hearers, know," + + "To rank our chosen truth with such a show" + + "As fool and fight is, beside forfeiting" + + "Our own brains, and the opinion that we bring," + + "To make that only true we now intend," + + "Will leave us never an understanding friend." + + "Therefore, for goodness' sake, and as you are known" + + "The first and happiest hearers of the town," + + "Be sad, as we would make ye: think ye see" + + "The very persons of our noble story" + + "As they were living; think you see them great," + + "And follow'd with the general throng and sweat" + + "Of thousand friends; then in a moment, see" + + "How soon this mightiness meets misery:" + + "And, if you can be merry then, I'll say" + + "A man may weep upon his wedding-day.", + + "First, heaven be the record to my speech!" + + "In the devotion of a subject's love," + + "Tendering the precious safety of my prince," + + "And free from other misbegotten hate," + + "Come I appellant to this princely presence." + + "Now, Thomas Mowbray, do I turn to thee," + + "And mark my greeting well; for what I speak" + + "My body shall make good upon this earth," + + "Or my divine soul answer it in heaven." + + "Thou art a traitor and a miscreant," + + "Too good to be so and too bad to live," + + "Since the more fair and crystal is the sky," + + "The uglier seem the clouds that in it fly." + + "Once more, the more to aggravate the note," + + "With a foul traitor's name stuff I thy throat;" + + "And wish, so please my sovereign, ere I move," + + "What my tongue speaks my right drawn sword may prove.", + + "Now is the winter of our discontent" + + "Made glorious summer by this sun of York;" + + "And all the clouds that lour'd upon our house" + + "In the deep bosom of the ocean buried." + + "Now are our brows bound with victorious wreaths;" + + "Our bruised arms hung up for monuments;" + + "Our stern alarums changed to merry meetings," + + "Our dreadful marches to delightful measures." + + "Grim-visaged war hath smooth'd his wrinkled front;" + + "And now, instead of mounting barded steeds" + + "To fright the souls of fearful adversaries," + + "He capers nimbly in a lady's chamber" + + "To the lascivious pleasing of a lute." + + "But I, that am not shaped for sportive tricks," + + "Nor made to court an amorous looking-glass;" + + "I, that am rudely stamp'd, and want love's majesty" + + "To strut before a wanton ambling nymph;" + + "I, that am curtail'd of this fair proportion," + + "Cheated of feature by dissembling nature," + + "Deformed, unfinish'd, sent before my time" + + "Into this breathing world, scarce half made up," + + "And that so lamely and unfashionable" + + "That dogs bark at me as I halt by them;" + + "Why, I, in this weak piping time of peace," + + "Have no delight to pass away the time," + + "Unless to spy my shadow in the sun" + + "And descant on mine own deformity:" + + "And therefore, since I cannot prove a lover," + + "To entertain these fair well-spoken days," + + "I am determined to prove a villain" + + "And hate the idle pleasures of these days." + + "Plots have I laid, inductions dangerous," + + "By drunken prophecies, libels and dreams," + + "To set my brother Clarence and the king" + + "In deadly hate the one against the other:" + + "And if King Edward be as true and just" + + "As I am subtle, false and treacherous," + + "This day should Clarence closely be mew'd up," + + "About a prophecy, which says that 'G'" + + "Of Edward's heirs the murderer shall be." + + "Dive, thoughts, down to my soul: here" + + "Clarence comes.", + + "To bait fish withal: if it will feed nothing else," + + "it will feed my revenge. He hath disgraced me, and" + + "hindered me half a million; laughed at my losses," + + "mocked at my gains, scorned my nation, thwarted my" + + "bargains, cooled my friends, heated mine" + + "enemies; and what's his reason? I am a Jew. Hath" + + "not a Jew eyes? hath not a Jew hands, organs," + + "dimensions, senses, affections, passions? fed with" + + "the same food, hurt with the same weapons, subject" + + "to the same diseases, healed by the same means," + + "warmed and cooled by the same winter and summer, as" + + "a Christian is? If you prick us, do we not bleed?" + + "if you tickle us, do we not laugh? if you poison" + + "us, do we not die? and if you wrong us, shall we not" + + "revenge? If we are like you in the rest, we will" + + "resemble you in that. If a Jew wrong a Christian," + + "what is his humility? Revenge. If a Christian" + + "wrong a Jew, what should his sufferance be by" + + "Christian example? Why, revenge. The villany you" + + "teach me, I will execute, and it shall go hard but I" + + "will better the instruction.", + + "Virtue! a fig! 'tis in ourselves that we are thus" + + "or thus. Our bodies are our gardens, to the which" + + "our wills are gardeners: so that if we will plant" + + "nettles, or sow lettuce, set hyssop and weed up" + + "thyme, supply it with one gender of herbs, or" + + "distract it with many, either to have it sterile" + + "with idleness, or manured with industry, why, the" + + "power and corrigible authority of this lies in our" + + "wills. If the balance of our lives had not one" + + "scale of reason to poise another of sensuality, the" + + "blood and baseness of our natures would conduct us" + + "to most preposterous conclusions: but we have" + + "reason to cool our raging motions, our carnal" + + "stings, our unbitted lusts, whereof I take this that" + + "you call love to be a sect or scion.", + + "Blow, winds, and crack your cheeks! rage! blow!" + + "You cataracts and hurricanoes, spout" + + "Till you have drench'd our steeples, drown'd the cocks!" + + "You sulphurous and thought-executing fires," + + "Vaunt-couriers to oak-cleaving thunderbolts," + + "Singe my white head! And thou, all-shaking thunder," + + "Smite flat the thick rotundity o' the world!" + + "Crack nature's moulds, an germens spill at once," + + "That make ingrateful man!" + }; +} diff --git a/samples/ApiDemos/src/com/example/android/apis/app/FragmentAnim.java b/samples/ApiDemos/src/com/example/android/apis/app/FragmentAnim.java new file mode 100644 index 000000000..227a2fb93 --- /dev/null +++ b/samples/ApiDemos/src/com/example/android/apis/app/FragmentAnim.java @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.android.apis.app; + +import com.example.android.apis.R; + +import android.app.Activity; +import android.app.Fragment; +import android.app.FragmentTransaction; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.View.OnClickListener; +import android.view.animation.AnimationUtils; +import android.widget.Button; +import android.widget.TextView; + +/** + * Demonstration of animations when changing fragment states. + */ +public class FragmentAnim extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.fragment_anim); + + addShowHideListener(R.id.frag1hide, findFragmentById(R.id.fragment1)); + addShowHideListener(R.id.frag2hide, findFragmentById(R.id.fragment2)); + } + + void addShowHideListener(int buttonId, final Fragment fragment) { + final Button button = (Button)findViewById(buttonId); + button.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + FragmentTransaction ft = openFragmentTransaction(); + ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); + if (fragment.isHidden()) { + button.setAnimation(AnimationUtils.loadAnimation( + FragmentAnim.this, android.R.anim.slide_in_left)); + ft.show(fragment); + } else { + button.setAnimation(AnimationUtils.loadAnimation( + FragmentAnim.this, android.R.anim.slide_out_right)); + ft.hide(fragment); + } + ft.commit(); + } + }); + } + + public static class FirstFragment extends Fragment { + TextView mTextView; + + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View v = inflater.inflate(R.layout.labeled_text_edit, container, false); + View tv = v.findViewById(R.id.msg); + ((TextView)tv).setText("The fragment saves and restores this text."); + + // Retrieve the text editor, and restore the last saved state if needed. + mTextView = (TextView)v.findViewById(R.id.saved); + if (savedInstanceState != null) { + mTextView.setText(savedInstanceState.getCharSequence("text")); + } + return v; + } + + @Override + public void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + + // Remember the current text, to restore if we later restart. + outState.putCharSequence("text", mTextView.getText()); + } + } + + public static class SecondFragment extends Fragment { + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View v = inflater.inflate(R.layout.labeled_text_edit, container, false); + View tv = v.findViewById(R.id.msg); + ((TextView)tv).setText("The TextView saves and restores this text."); + + // Retrieve the text editor and tell it to save and restore its state. + // Note that you will often set this in the layout XML, but since + // we are sharing our layout with the other fragment we will customize + // it here. + ((TextView)v.findViewById(R.id.saved)).setSaveEnabled(true); + return v; + } + } +} diff --git a/samples/ApiDemos/src/com/example/android/apis/app/FragmentLayout.java b/samples/ApiDemos/src/com/example/android/apis/app/FragmentLayout.java index fdf8e1d68..71cae8a85 100644 --- a/samples/ApiDemos/src/com/example/android/apis/app/FragmentLayout.java +++ b/samples/ApiDemos/src/com/example/android/apis/app/FragmentLayout.java @@ -17,79 +17,115 @@ package com.example.android.apis.app; import com.example.android.apis.R; +import com.example.android.apis.Shakespeare; import android.app.Activity; import android.app.Fragment; +import android.app.FragmentTransaction; +import android.content.Intent; +import android.content.res.Configuration; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.View.OnClickListener; +import android.view.animation.AnimationUtils; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.ListView; +import android.widget.ScrollView; import android.widget.TextView; +/** + * Demonstration of using fragments to implement different activity layouts. + * This sample provides a different layout (and activity flow) when run in + * landscape. + */ public class FragmentLayout extends Activity { - View mFirstFragmentView; - View mSecondFragmentView; - - Fragment mFirstFragment; - Fragment mSecondFragment; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_layout); - mFirstFragmentView = findViewById(R.id.fragment1); - mSecondFragmentView = findViewById(R.id.fragment2); - mFirstFragment = findFragmentById(R.id.fragment1); - mSecondFragment = findFragmentById(R.id.fragment2); } - static class FirstFragment extends Fragment { - TextView mTextView; - - // Explicit constructor needed for inflation. - public FirstFragment() { + public static class DialogActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + if (getResources().getConfiguration().orientation + == Configuration.ORIENTATION_LANDSCAPE) { + // If the screen is now in landscape mode, we can show the + // dialog in-line with the list so we don't need this activity. + finish(); + return; + } + + DialogFragment dialog = new DialogFragment(); + this.openFragmentTransaction().add(android.R.id.content, dialog).commit(); + dialog.setText(getIntent().getIntExtra("text", -1)); } - + } + + public static class TitlesFragment extends Fragment + implements AdapterView.OnItemClickListener { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View v = inflater.inflate(R.layout.labeled_text_edit, container, false); - View tv = v.findViewById(R.id.msg); - ((TextView)tv).setText("The fragment saves and restores this text."); - - // Retrieve the text editor, and restore the last saved state if needed. - mTextView = (TextView)v.findViewById(R.id.saved); - if (savedInstanceState != null) { - mTextView.setText(savedInstanceState.getCharSequence("text")); + ListView list = new ListView(getActivity()); + list.setDrawSelectorOnTop(false); + list.setAdapter(new ArrayAdapter(getActivity(), + android.R.layout.simple_list_item_1, Shakespeare.TITLES)); + list.setOnItemClickListener(this); + list.setId(android.R.id.list); // set id to allow state save/restore. + return list; + } + + public void onItemClick(AdapterView parent, View view, int position, long id) { + DialogFragment frag = (DialogFragment)getActivity().findFragmentById(R.id.dialog); + if (frag != null && frag.isVisible()) { + frag.setText((int)id); + } else { + Intent intent = new Intent(); + intent.setClass(getActivity(), DialogActivity.class); + intent.putExtra("text", (int)id); + startActivity(intent); + } + } + } + + public static class DialogFragment extends Fragment { + int mDisplayedText = -1; + TextView mText; + + public void setText(int id) { + mDisplayedText = id; + if (mText != null && id >= 0) { + mText.setText(Shakespeare.DIALOGUE[id]); + } + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (savedInstanceState != null) { + mDisplayedText = savedInstanceState.getInt("text", -1); } - return v; } @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - - // Remember the current text, to restore if we later restart. - outState.putCharSequence("text", mTextView.getText()); + outState.putInt("text", mDisplayedText); } - } - - static class SecondFragment extends Fragment { - // Explicit constructor needed for inflation. - public SecondFragment() { - } - + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View v = inflater.inflate(R.layout.labeled_text_edit, container, false); - View tv = v.findViewById(R.id.msg); - ((TextView)tv).setText("The TextView saves and restores this text."); - - // Retrieve the text editor and tell it to save and restore its state. - // Note that you will often set this in the layout XML, but since - // we are sharing our layout with the other fragment we will customize - // it here. - ((TextView)v.findViewById(R.id.saved)).setSaveEnabled(true); - return v; + ScrollView scroller = new ScrollView(getActivity()); + mText = new TextView(getActivity()); + scroller.addView(mText); + setText(mDisplayedText); + return scroller; } } } diff --git a/samples/ApiDemos/src/com/example/android/apis/app/FragmentReceiveResult.java b/samples/ApiDemos/src/com/example/android/apis/app/FragmentReceiveResult.java index 37b542a56..a3699b1df 100644 --- a/samples/ApiDemos/src/com/example/android/apis/app/FragmentReceiveResult.java +++ b/samples/ApiDemos/src/com/example/android/apis/app/FragmentReceiveResult.java @@ -32,11 +32,11 @@ public class FragmentReceiveResult extends Activity { // Do first time initialization -- add fragment. Fragment newFragment = new ReceiveResultFragment(); FragmentTransaction ft = openFragmentTransaction(); - ft.add(newFragment, R.id.simple_fragment).commit(); + ft.add(R.id.simple_fragment, newFragment).commit(); } } - static class ReceiveResultFragment extends Fragment { + public static class ReceiveResultFragment extends Fragment { // Definition of the one requestCode we use for receiving resuls. static final private int GET_CODE = 0; @@ -51,9 +51,6 @@ public class FragmentReceiveResult extends Activity { } }; - public ReceiveResultFragment() { - } - @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/samples/ApiDemos/src/com/example/android/apis/app/FragmentRetainInstance.java b/samples/ApiDemos/src/com/example/android/apis/app/FragmentRetainInstance.java index da0d47bc4..66794cf32 100644 --- a/samples/ApiDemos/src/com/example/android/apis/app/FragmentRetainInstance.java +++ b/samples/ApiDemos/src/com/example/android/apis/app/FragmentRetainInstance.java @@ -67,7 +67,7 @@ public class FragmentRetainInstance extends Activity { * activity instances. It represents some ongoing work, here a thread * we have that sits around incrementing a progress indicator. */ - static class RetainedFragment extends Fragment { + public static class RetainedFragment extends Fragment { ProgressBar mProgressBar; int mPosition; boolean mReady = false; diff --git a/samples/ApiDemos/src/com/example/android/apis/app/FragmentStack.java b/samples/ApiDemos/src/com/example/android/apis/app/FragmentStack.java index 48d367e94..c7754b6ce 100644 --- a/samples/ApiDemos/src/com/example/android/apis/app/FragmentStack.java +++ b/samples/ApiDemos/src/com/example/android/apis/app/FragmentStack.java @@ -49,7 +49,7 @@ public class FragmentStack extends Activity { // Do first time initialization -- add initial fragment. Fragment newFragment = new CountingFragment(mStackLevel); FragmentTransaction ft = openFragmentTransaction(); - ft.add(newFragment, R.id.simple_fragment).commit(); + ft.add(R.id.simple_fragment, newFragment).commit(); } else { mStackLevel = savedInstanceState.getInt("level"); } @@ -65,17 +65,17 @@ public class FragmentStack extends Activity { mStackLevel++; Fragment newFragment = new CountingFragment(mStackLevel); FragmentTransaction ft = openFragmentTransaction(); - ft.replace(newFragment, R.id.simple_fragment); - ft.setTransition(FragmentTransaction.TRANSIT_ACTIVITY_OPEN); + ft.replace(R.id.simple_fragment, newFragment); + ft.setTransition(FragmentTransaction.TRANSIT_WALLPAPER_INTRA_OPEN); ft.addToBackStack(null); ft.commit(); } - static class CountingFragment extends Fragment { + public static class CountingFragment extends Fragment { int mNum; public CountingFragment() { - mNum = 0; + mNum = -1; } public CountingFragment(int num) { diff --git a/samples/ApiDemos/src/com/example/android/apis/view/List4.java b/samples/ApiDemos/src/com/example/android/apis/view/List4.java index a140e606f..9c18a5d4b 100644 --- a/samples/ApiDemos/src/com/example/android/apis/view/List4.java +++ b/samples/ApiDemos/src/com/example/android/apis/view/List4.java @@ -16,8 +16,8 @@ package com.example.android.apis.view; -//Need the following import to get access to the app resources, since this -//class is in a sub-package. +import com.example.android.apis.Shakespeare; + import android.app.ListActivity; import android.content.Context; import android.os.Bundle; @@ -59,7 +59,7 @@ public class List4 extends ListActivity { * @see android.widget.ListAdapter#getCount() */ public int getCount() { - return mTitles.length; + return Shakespeare.TITLES.length; } /** @@ -92,12 +92,12 @@ public class List4 extends ListActivity { public View getView(int position, View convertView, ViewGroup parent) { SpeechView sv; if (convertView == null) { - sv = new SpeechView(mContext, mTitles[position], - mDialogue[position]); + sv = new SpeechView(mContext, Shakespeare.TITLES[position], + Shakespeare.DIALOGUE[position]); } else { sv = (SpeechView) convertView; - sv.setTitle(mTitles[position]); - sv.setDialogue(mDialogue[position]); + sv.setTitle(Shakespeare.TITLES[position]); + sv.setDialogue(Shakespeare.DIALOGUE[position]); } return sv; @@ -107,226 +107,6 @@ public class List4 extends ListActivity { * Remember our context so we can use it when constructing views. */ private Context mContext; - - /** - * Our data, part 1. - */ - private String[] mTitles = - { - "Henry IV (1)", - "Henry V", - "Henry VIII", - "Richard II", - "Richard III", - "Merchant of Venice", - "Othello", - "King Lear" - }; - - /** - * Our data, part 2. - */ - private String[] mDialogue = - { - "So shaken as we are, so wan with care," + - "Find we a time for frighted peace to pant," + - "And breathe short-winded accents of new broils" + - "To be commenced in strands afar remote." + - "No more the thirsty entrance of this soil" + - "Shall daub her lips with her own children's blood;" + - "Nor more shall trenching war channel her fields," + - "Nor bruise her flowerets with the armed hoofs" + - "Of hostile paces: those opposed eyes," + - "Which, like the meteors of a troubled heaven," + - "All of one nature, of one substance bred," + - "Did lately meet in the intestine shock" + - "And furious close of civil butchery" + - "Shall now, in mutual well-beseeming ranks," + - "March all one way and be no more opposed" + - "Against acquaintance, kindred and allies:" + - "The edge of war, like an ill-sheathed knife," + - "No more shall cut his master. Therefore, friends," + - "As far as to the sepulchre of Christ," + - "Whose soldier now, under whose blessed cross" + - "We are impressed and engaged to fight," + - "Forthwith a power of English shall we levy;" + - "Whose arms were moulded in their mothers' womb" + - "To chase these pagans in those holy fields" + - "Over whose acres walk'd those blessed feet" + - "Which fourteen hundred years ago were nail'd" + - "For our advantage on the bitter cross." + - "But this our purpose now is twelve month old," + - "And bootless 'tis to tell you we will go:" + - "Therefore we meet not now. Then let me hear" + - "Of you, my gentle cousin Westmoreland," + - "What yesternight our council did decree" + - "In forwarding this dear expedience.", - - "Hear him but reason in divinity," + - "And all-admiring with an inward wish" + - "You would desire the king were made a prelate:" + - "Hear him debate of commonwealth affairs," + - "You would say it hath been all in all his study:" + - "List his discourse of war, and you shall hear" + - "A fearful battle render'd you in music:" + - "Turn him to any cause of policy," + - "The Gordian knot of it he will unloose," + - "Familiar as his garter: that, when he speaks," + - "The air, a charter'd libertine, is still," + - "And the mute wonder lurketh in men's ears," + - "To steal his sweet and honey'd sentences;" + - "So that the art and practic part of life" + - "Must be the mistress to this theoric:" + - "Which is a wonder how his grace should glean it," + - "Since his addiction was to courses vain," + - "His companies unletter'd, rude and shallow," + - "His hours fill'd up with riots, banquets, sports," + - "And never noted in him any study," + - "Any retirement, any sequestration" + - "From open haunts and popularity.", - - "I come no more to make you laugh: things now," + - "That bear a weighty and a serious brow," + - "Sad, high, and working, full of state and woe," + - "Such noble scenes as draw the eye to flow," + - "We now present. Those that can pity, here" + - "May, if they think it well, let fall a tear;" + - "The subject will deserve it. Such as give" + - "Their money out of hope they may believe," + - "May here find truth too. Those that come to see" + - "Only a show or two, and so agree" + - "The play may pass, if they be still and willing," + - "I'll undertake may see away their shilling" + - "Richly in two short hours. Only they" + - "That come to hear a merry bawdy play," + - "A noise of targets, or to see a fellow" + - "In a long motley coat guarded with yellow," + - "Will be deceived; for, gentle hearers, know," + - "To rank our chosen truth with such a show" + - "As fool and fight is, beside forfeiting" + - "Our own brains, and the opinion that we bring," + - "To make that only true we now intend," + - "Will leave us never an understanding friend." + - "Therefore, for goodness' sake, and as you are known" + - "The first and happiest hearers of the town," + - "Be sad, as we would make ye: think ye see" + - "The very persons of our noble story" + - "As they were living; think you see them great," + - "And follow'd with the general throng and sweat" + - "Of thousand friends; then in a moment, see" + - "How soon this mightiness meets misery:" + - "And, if you can be merry then, I'll say" + - "A man may weep upon his wedding-day.", - - "First, heaven be the record to my speech!" + - "In the devotion of a subject's love," + - "Tendering the precious safety of my prince," + - "And free from other misbegotten hate," + - "Come I appellant to this princely presence." + - "Now, Thomas Mowbray, do I turn to thee," + - "And mark my greeting well; for what I speak" + - "My body shall make good upon this earth," + - "Or my divine soul answer it in heaven." + - "Thou art a traitor and a miscreant," + - "Too good to be so and too bad to live," + - "Since the more fair and crystal is the sky," + - "The uglier seem the clouds that in it fly." + - "Once more, the more to aggravate the note," + - "With a foul traitor's name stuff I thy throat;" + - "And wish, so please my sovereign, ere I move," + - "What my tongue speaks my right drawn sword may prove.", - - "Now is the winter of our discontent" + - "Made glorious summer by this sun of York;" + - "And all the clouds that lour'd upon our house" + - "In the deep bosom of the ocean buried." + - "Now are our brows bound with victorious wreaths;" + - "Our bruised arms hung up for monuments;" + - "Our stern alarums changed to merry meetings," + - "Our dreadful marches to delightful measures." + - "Grim-visaged war hath smooth'd his wrinkled front;" + - "And now, instead of mounting barded steeds" + - "To fright the souls of fearful adversaries," + - "He capers nimbly in a lady's chamber" + - "To the lascivious pleasing of a lute." + - "But I, that am not shaped for sportive tricks," + - "Nor made to court an amorous looking-glass;" + - "I, that am rudely stamp'd, and want love's majesty" + - "To strut before a wanton ambling nymph;" + - "I, that am curtail'd of this fair proportion," + - "Cheated of feature by dissembling nature," + - "Deformed, unfinish'd, sent before my time" + - "Into this breathing world, scarce half made up," + - "And that so lamely and unfashionable" + - "That dogs bark at me as I halt by them;" + - "Why, I, in this weak piping time of peace," + - "Have no delight to pass away the time," + - "Unless to spy my shadow in the sun" + - "And descant on mine own deformity:" + - "And therefore, since I cannot prove a lover," + - "To entertain these fair well-spoken days," + - "I am determined to prove a villain" + - "And hate the idle pleasures of these days." + - "Plots have I laid, inductions dangerous," + - "By drunken prophecies, libels and dreams," + - "To set my brother Clarence and the king" + - "In deadly hate the one against the other:" + - "And if King Edward be as true and just" + - "As I am subtle, false and treacherous," + - "This day should Clarence closely be mew'd up," + - "About a prophecy, which says that 'G'" + - "Of Edward's heirs the murderer shall be." + - "Dive, thoughts, down to my soul: here" + - "Clarence comes.", - - "To bait fish withal: if it will feed nothing else," + - "it will feed my revenge. He hath disgraced me, and" + - "hindered me half a million; laughed at my losses," + - "mocked at my gains, scorned my nation, thwarted my" + - "bargains, cooled my friends, heated mine" + - "enemies; and what's his reason? I am a Jew. Hath" + - "not a Jew eyes? hath not a Jew hands, organs," + - "dimensions, senses, affections, passions? fed with" + - "the same food, hurt with the same weapons, subject" + - "to the same diseases, healed by the same means," + - "warmed and cooled by the same winter and summer, as" + - "a Christian is? If you prick us, do we not bleed?" + - "if you tickle us, do we not laugh? if you poison" + - "us, do we not die? and if you wrong us, shall we not" + - "revenge? If we are like you in the rest, we will" + - "resemble you in that. If a Jew wrong a Christian," + - "what is his humility? Revenge. If a Christian" + - "wrong a Jew, what should his sufferance be by" + - "Christian example? Why, revenge. The villany you" + - "teach me, I will execute, and it shall go hard but I" + - "will better the instruction.", - - "Virtue! a fig! 'tis in ourselves that we are thus" + - "or thus. Our bodies are our gardens, to the which" + - "our wills are gardeners: so that if we will plant" + - "nettles, or sow lettuce, set hyssop and weed up" + - "thyme, supply it with one gender of herbs, or" + - "distract it with many, either to have it sterile" + - "with idleness, or manured with industry, why, the" + - "power and corrigible authority of this lies in our" + - "wills. If the balance of our lives had not one" + - "scale of reason to poise another of sensuality, the" + - "blood and baseness of our natures would conduct us" + - "to most preposterous conclusions: but we have" + - "reason to cool our raging motions, our carnal" + - "stings, our unbitted lusts, whereof I take this that" + - "you call love to be a sect or scion.", - - "Blow, winds, and crack your cheeks! rage! blow!" + - "You cataracts and hurricanoes, spout" + - "Till you have drench'd our steeples, drown'd the cocks!" + - "You sulphurous and thought-executing fires," + - "Vaunt-couriers to oak-cleaving thunderbolts," + - "Singe my white head! And thou, all-shaking thunder," + - "Smite flat the thick rotundity o' the world!" + - "Crack nature's moulds, an germens spill at once," + - "That make ingrateful man!" - }; } /**