在Android中加载大文本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在Android中加载大文本相关的知识,希望对你有一定的参考价值。
在我的应用程序中,我试图从网站复制文本并将其粘贴到我的strings.xml
文件中,并在保存strings.xml
文件后,我无法在我的textview中使用该字符串,当我尝试清理我的项目时,我的R.java获取删除,当我从strings.xml中删除该文本时,我保留了我的R.java。我想复制以下网站的文字。
http://mygogolfteetime.com/term-of-use
我的String值是:
<string name="terms_of_use">
Website Terms, Conditions, and Notices AgreementBetween Customer and GoGolf, L.P.
Welcome to the mygogolfteetime.com website (the "Website"). This Website is provided solely to assist customers in gathering tee time information, determining the availability of tee time-related goods and services, making legitimate reservations or otherwise transacting business with golf tee time suppliers, and for no other purposes. The terms "we", "us", "our" and "mygogolfteeetime.com" refer to GoGolf, L.P., a Texas limited partnership and/or our subsidiaries. The term "you" refers to the customer visiting the Website and/or booking a tee time through us on this Website, or through our customer service agents.
This Website is offered to you conditioned upon your acceptance without modification of all the terms, conditions, and notices set forth below (collectively, the "Agreement"). By accessing or using this Website in any manner, you agree to be bound by the Agreement. Please read the Agreement carefully. If you do not accept all of these terms and conditions, please do not use this Website. Be sure to return to this page periodically to review the most current version of the Agreement. We reserve the right at any time, at our sole discretion, to change or otherwise modify the Agreement without prior notice, and your continued access or use of this Website signifies your acceptance of the updated or modified Agreement.
Use of the Website
As a condition of your use of this Website, you warrant that
1. you are at least 18 years of age,
2. you possess the legal authority to create a binding legal obligation,
3. you will use this Website in accordance with this Agreement,
4. you will only use this Website to make legitimate reservations for you or for another person for whom you are legally authorized to act,
5. all information supplied by you on this Website is true, accurate, current and complete, and
6. if you have a mygogolfteetim.com account, you will safeguard your account information and will supervise and be completely responsible for any use of your account by anyone other than you. We retain the right at our sole discretion to deny access to anyone to this Website and the services we offer, at any time and for any reason, including, but not limited to, for violation of this Agreement.
Prohibited Activities
The content and information on this Website (including, but not limited to, price and availability of tee time services), as well as the infrastructure used to provide such content and information, is proprietary to us or our suppliers and providers. While you may make limited copies of your tee time itinerary (and related documents) for tee time reservations or services booked through this Website, you agree not to otherwise modify, copy, distribute, transmit, display, perform, reproduce, publish, license, create derivative works from, transfer, or sell or re-sell any information, software, products, or services obtained from or through this Website. Additionally, you agree not to:
1. use this Website or its contents for any commercial purpose;
2. make any speculative, false, or fraudulent reservation or any reservation in anticipation of demand;
3. access, monitor or copy any content or information of this Website using any robot, spider, scraper or other automated means or any manual process for any purpose without our express written permission;
4. violate the restrictions in any robot exclusion headers on this Website or bypass or circumvent other measures employed to prevent or limit access to this Website;
5. take any action that imposes, or may impose, in our discretion, an unreasonable or disproportionately large load on our infrastructure;
6. deep-link to any portion of this Website (including, without limitation, the purchase path for any tee time services) for any purpose without our express written permission; or
7. "frame", "mirror" or otherwise incorporate any part of this Website into any other website without our prior written authorization.
Supplier Rules and Restrictions
Separate terms and conditions will apply to your reservation and purchase of tee time - related goods and services that you select. Please read these separate terms and conditions carefully. You agree to abide by the terms and conditions of purchase imposed by any supplier with whom you elect to deal, including, but not limited to, payment of all amounts when due and compliance with the supplier's rules and restrictions regarding availability and use of fares, products, or services. You acknowledge that some third-party providers offering certain services and/or activities may require you to sign their liability waiver prior to participating in the service and/or activity they offer. You understand that any violation of any such supplier's rules and restrictions may result in cancellation of your tee time(s), in your being denied access to the applicable golf course product or services, in your forfeiting any monies paid for such reservation(s), and/or in our debiting your account for any costs we incur as a result of such violation.
Privacy Policy
GoGolf, LP. believes in protecting your privacy. Please click here to review our current Privacy Policy, which also governs your use of mygogolfteetime.com, to understand our practices: Privacy Policy.
Reviews, Comments and Other Submissions
We appreciate hearing from you. Please be aware that by submitting content to this Website by electronic mail, postings on this Website or otherwise, including any golf course reviews, photographs, video, questions, comments, suggestions, ideas or the like contained in any submissions (collectively, "Submissions"), you (a) grant GoGolf, LP. and its affiliates a nonexclusive, royalty-free, perpetual, transferable, irrevocable and fully sublicensable right to use, reproduce, modify, adapt, translate, distribute, publish, create derivative works from and publicly display and perform such Submissions throughout the world in any media, now known or hereafter devised; and (b) grant GoGolf, LP and its affiliates and sublicensees the right to use the name that you submit in connection with such Submission, if they choose. However, you acknowledge that GoGolf, LP may choose to provide attribution of your comments or reviews (for example, listing your name and hometown on a golf course review that you submit) at our discretion. You further grant GoGolf, LP the right to pursue at law any person or entity that violates your or GoGolf, LP rights in the Submissions by a breach of this Agreement. We take no responsibility and assume no liability for any Submissions posted or submitted by you. If you do not agree to these terms and conditions, please do not provide us with any Submissions.
You are fully responsible for the content of your Submissions, (specifically including, but not limited to, reviews posted to this Website). You are prohibited from posting or transmitting to or from this Website: (i) any unlawful, threatening, libelous, defamatory, obscene, pornographic, or other material or content that would violate rights of publicity and/or privacy or that would violate any law; (ii) any commercial material or content (including, but not limited to, solicitation of funds, advertising, or marketing of any good or services); and (iii) any material or content that infringes, misappropriates or violates any copyright, trademark, patent right or other proprietary right of any third party. You shall be solely liable for any damages resulting from any violation of the foregoing restrictions, or any other harm resulting from your posting of content to this Website. You acknowledge that GoGolf, LP has the right to control (e.g. use, publish, remove) any content you submit without notice to you. If you submit more than one review for the same hotel, only your most recent submission is eligible for use.
If you believe in good faith that materials hosted by us infringe your copyright, you (or your agent) may send us a written notice that includes the following information:
1. A clear identification of the copyrighted work you claim was infringed.
2. A clear identification of the material you claim is infringing the copyrighted work, and information that will allow us to locate that material on the Website, such as a link to the infringing material.
3. Your contact information so that we can reply to your complaint, preferably including an email address and telephone number.
4. A statement that you have a "good faith belief that the material that is claimed as copyright infringement is not authorized by the copyright owner, its agent, or the law."
5. A statement that "the information in the notification is accurate, and under penalty of perjury, the complaining party is authorized to act on behalf of the owner of an exclusive right that is allegedly infringed."
6. The notice must be signed by the person authorized to act on behalf of the owner of an exclusive right that is allegedly infringed.
Notices with respect to this Website should be sent to:: GoGolf, L.P., 13522 Pueblo Crossing San Antonio, TX 78232; gogolf_copyright@mygogolfteetime.com; by phone at 210.317.1210
We will review and address all notices that comply with the requirements above.
We suggest that you consult your legal advisor before filing a notice or counter-notice. Also, be aware that you may be liable for damages if you make a false claim of copyright infringement.
Pay Reservation Fee Now Online and Pay Green Fee Later at Golf Course
With all golf course, you will be responsible for paying green fees (cost to golf) at the golf course itself. You will be charged the amount in the currency that you select immediately for the Reservation Fee. You will pay later for all green fees and other associated fee the golf course may charge at the golf course itself, the golf course will charge you in the local currency of the relevant golf course at the time of your tee time. Tax rates and foreign exchange rates could change in the time between booking and stay.
GoGolf, LP. Change Or Cancellation Fees
GoGolf, LP. will not refund any booking fees once booking has been accepted by user. You can change or cancel your tee time booking online. You may still be subject to change and cancellation fees that our tee time suppliers impose and require us to pass on, as indicated in the rules and restrictions for the tee time reservation. Valid only for tee time bookings made after May 10, 2012. Golf Courses and other suppliers may impose their own change and/or cancellation fees. Change and cancellation requirements and penalties vary by golf course. Check your booking confirmation for details. To change or cancel your tee time booking, go online to www.mygogolfteetime.com. These terms and conditions may not be changed by any unauthorized person, including employees of GoGolf, LP.
You agree to pay the booking fees to GoGolf, LP and any golf course required cancellation or change fees that you incur. In limited cases, some golf courses do not permit changes to or cancellations of reservations after they are made, as indicated in the rules and restrictions for the tee time reservation. You agree to abide by the terms and conditions imposed with respect to your tee time reservations.
General Terms
GoGolf, LP.reserves the right to discontinue the participation privileges of any individual who engages in any fraudulent activity or uses the Program in a manner inconsistent with these Terms & Conditions or any federal or state laws, statutes, or ordinances. Discontinued participation privileges may result in the loss of all benefits. In addition to discontinuance of participation privileges, GoGolf, LP shall have the right to take appropriate administrative and/or legal action, including criminal prosecution, as it deems necessary. While you are enrolled in mygogolfteetime.com program, we may communicate with you via email regarding updates on your account or transactions. Except where prohibited, you agree that any and all disputes, claims, and causes of action arising out of, or connected with, the tee time reservations shall be resolved individually, without resort to any form of class action, and exclusively by the appropriate court located in Bexar County, Texas.
LIABILITY DISCLAIMER THE INFORMATION, SOFTWARE, PRODUCTS, AND SERVICES PUBLISHED ON THIS WEBSITE MAY INCLUDE INACCURACIES OR ERRORS, INCLUDING PRICING ERRORS. IN PARTICULAR, GOGOLF, LP. ITS SUBSIDIARIES AND CORPORATE AFFILIATESDO NOT GUARANTEE THE ACCURACY OF, AND DISCLAIM ALL LIABILITY FOR ANY ERRORS OR OTHER INACCURACIES RELATING TO THE INFORMATION AND DESCRIPTION OF THE GOLF COURSE AND OTHER PRODUCTS DISPLAYED ON THIS WEBSITE (INCLUDING, WITHOUT LIMITATION, THE PRICING, PHOTOGRAPHS, LIST OF GOLF COURSE AMENITIES, GENERAL PRODUCT DESCRIPTIONS, ETC.), MUCH OF WHICH INFORMATION IS PROVIDED BY THE RESPECTIVE GOLF COURSE. IN ADDITION, GOGOLF, LP. EXPRESSLY RESERVES THE RIGHT TO CORRECT ANY PRICING ERRORS ON OUR WEBSITE AND/OR ON PENDING RESERVATIONS MADE UNDER AN INCORRECT PRICE. IN SUCH EVENT, WE WILL OFFER YOU THE OPPORTUNITY TO KEEP YOUR PENDING RESERVATION AT THE CORRECT PRICE OR, AT YOUR OPTION, WE WILL CANCEL YOUR RESERVATION WITHOUT ANY CHANGE OR CANCELLATION FEES.
GOLF COURSE RATINGS DISPLAYED ON THIS WEBSITE ARE INTENDED AS ONLY GENERAL GUIDELINES, AND THE GOGOLF, LP. AFFILIATES DO NOT GUARANTEE THE ACCURACY OF THE RATINGS. THE GOGOLF, LP. COMPANIES, THE GOGOLF, LP.AFFILIATES AND THEIR RESPECTIVE SUPPLIERS MAKE NO GUARANTEES ABOUT THE AVAILABILITY OF SPECIFIC PRODUCTS AND SERVICES. THE GOGOLF, LP. COMPANIES, THE GOGOLF, LP. AFFILIATES AND THEIR RESPECTIVE GOLF COURSE MAY MAKE IMPROVEMENTS AND/OR CHANGES ON THIS WEBSITE AT ANY TIME.
THE GOGOLF, LP.COMPANIES, THE GOGOLF, LP.AFFILIATES, AND THEIR RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE INFORMATION, SOFTWARE, PRODUCTS, AND SERVICES CONTAINED ON THIS WEBSITE FOR ANY PURPOSE, AND THE INCLUSION OR OFFERING OF ANY PRODUCTS OR SERVICES ON THIS WEBSITE DOES NOT CONSTITUTE ANY ENDORSEMENT OR RECOMMENDATION OF SUCH PRODUCTS OR SERVICES BY THE GOGOLF, LP.COMPANIES OR.THE GOGOLF, LP.AFFILIATES. ALL SUCH INFORMATION, SOFTWARE, PRODUCTS, AND SERVICES ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. THEGOGOLF, LP.COMPANIES, THE GOGOLF, LP.AFFILIATES, AND THEIR RESPECTIVE GOLF COURSES DISCLAIM ALL WARRANTIES AND CONDITIONS THAT THIS WEBSITE, ITS SERVERS OR ANY EMAIL SENT FROM THE GOGOLF, LP.COMPANIES, THE GOGOLF, LP.AFFILIATES, AND/OR THEIR RESPECTIVE SUPPLIERS ARE FREE OF VIRUSES OR OTHER HARMFUL COMPONENTS. THE GOGOLF, LP.COMPANIES, THE GOGOLF, LP.AFFILIATES, AND THEIR RESPECTIVE GOLG COURSES HEREBY DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THIS INFORMATION, SOFTWARE, PRODUCTS, AND SERVICES, INCLUDING ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND NONINFRINGEMENT.
THE GOLF COURSES AND OTHER SUPPLIERS PROVIDING TEE TIME OR OTHER SERVICES ON THIS WEBSITE ARE INDEPENDENT CONTRACTORS AND NOT AGENTS OR EMPLOYEES OF THE GOGOLF, LP.COMPANIES, OR THE GOGOLF, LP.AFFILIATES. THE GOGOLF, LP.COMPANIES AND THE GOGOLF, LP.AFFILIATES ARE NOT LIABLE FOR THE ACTS, ERRORS, OMISSIONS, REPRESENTATIONS, WARRANTIES, BREACHES OR NEGLIGENCE OF ANY SUCH SUPPLIERS OR FOR ANY PERSONAL INJURIES, DEATH, PROPERTY DAMAGE, OR OTHER DAMAGES OR EXPENSES RESULTING THEREFROM. THEGOGOLF, LP.COMPANIES AND THE GOGOLF, LP. AFFILIATES HAVE NO LIABILITY AND WILL MAKE NO REFUND IN THE EVENT OF ANY DELAY, CANCELLATION, OVERBOOKING, STRIKE, FORCE MAJEURE OR OTHER CAUSES BEYOND THEIR DIRECT CONTROL, AND THEY HAVE NO RESPONSIBILITY FOR ANY ADDITIONAL EXPENSE, OMISSIONS, DELAYS, RE-ROUTING OR ACTS OF ANY GOVERNMENT OR AUTHORITY.
IN NO EVENT SHALL THE GOGOLF, LP.COMPANIES, THE GOGOLF, LP.AFFILIATES, AND/OR THEIR RESPECTIVE SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, PUNITIVE, INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF, OR IN ANY WAY CONNECTED WITH, YOUR ACCESS TO, DISPLAY OF OR USE OF THIS WEBSITE OR WITH THE DELAY OR INABILITY TO ACCESS, DISPLAY OR USE THIS WEBSITE (INCLUDING, BUT NOT LIMITED TO, YOUR RELIANCE UPON OPINIONS APPEARING ON THIS WEB SITE; ANY COMPUTER VIRUSES, INFORMATION, SOFTWARE, LINKED SITES, PRODUCTS, AND SERVICES OBTAINED THROUGH THIS WEBSITE; OR OTHERWISE ARISING OUT OF THE ACCESS TO, DISPLAY OF OR USE OF THIS WEBSITE) WHETHER BASED ON A THEORY OF NEGLIGENCE, CONTRACT, TORT, STRICT LIABILITY, OR OTHERWISE, AND EVEN IF THEGOGOLF, LP.COMPANIES, THE GOGOLF, LP.AFFILIATES AND/OR THEIR RESPECTIVE GOLF COURSES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
If, despite the limitation above, the GOGOLF, LP.Companies, the GOGOLF, LP. Affiliates or their respective suppliers are found liable for any loss or damage which arises out of or in any way connected with any of the occurrences described above, then the GOGOLF, LP.Companies, theGOGOLF, LP. Affiliates or their respective suppliers liabilities will in no event exceed, in the aggregate, the greater of (a) the transaction fees assessed for your transactions on this Website, or (b) One-Hundred Dollars (US$100.00).
The limitation of liability reflects the allocation of risk between the parties. The limitations specified in this section will survive and apply even if any limited remedy specified in these terms is found to have failed of its essential purpose. The limitations of liability provided in these terms inure to the benefit of the GOGOLF, LP.Companies, the GOGOLF, LP.Affiliates, and/or their respective suppliers.
Indemnification
You agree to defend and indemnify the GOGOLF, LP.Companies, the GOGOLF, LP.Affiliates, and/or their respective suppliers and any of their officers, directors, employees and agents from and against any claims, causes of action, demands, recoveries, losses, damages, fines, penalties or other costs or expenses of any kind or nature including but not limited to reasonable legal and accounting fees, brought by third parties as a result of:
(a) your breach of this Agreement or the documents referenced herein;
(b) your violation of any law or the rights of a third party; or
(c) your use of this Website.
Links To Third-Party Sites
This Website may contain hyperlinks to websites operated by parties other than GoGolf. Such hyperlinks are provided for your reference only. We do not control such websites and are not responsible for their contents or the privacy or other practices of such websites. Further, it is up to you to take precautions to ensure that whatever links you select or software you download (whether from this Website or other websites) is free of such items as viruses, worms, trojan horses, defects and other items of a destructive nature. Our inclusion of hyperlinks to such websites does not imply any endorsement of the material on such websites or any association with their operators.
Software Available On This Website
Any software that is made available to download from this Website ("Software") is the copyrighted work of UDIG dbaGOGOLF, LP., and/or our respective suppliers. Your use of such Software is governed by the terms of the end user license agreement, if any, which accompanies, or is included with, the Software ("License Agreement"). You may not install or use any Software that is accompanied by or includes a License Agreement unless you first agree to the License Agreement terms. For any Software made available for download on this Website not accompanied by a License Agreement, we hereby grant to you, the user, a limited, personal, nontransferable license to use the Software for viewing and otherwise using this Website in accordance with these terms and conditions and for no other purpose.
Please note that all Software, including, without limitation, all html code and Active X controls contained on this Website, is owned by UDIG dba GOGOLF, LP. Affiliates, and/or our respective suppliers, and is protected by copyright laws and international treaty provisions. Any reproduction or redistribution of the Software is expressly prohibited, and may result in severe civil and criminal penalties. Violators will be prosecuted to the maximum extent possible.
WITHOUT LIMITING THE FOREGOING, COPYING OR REPRODUCTION OF THE SOFTWARE TO ANY OTHER SERVER OR LOCATION FOR FURTHER REPRODUCTION OR REDISTRIBUTION IS EXPRESSLY PROHIBITED. THE SOFTWARE IS WARRANTED, IF AT ALL, ONLY ACCORDING TO THE TERMS OF THE LICENSE AGREEMENT.
Currency Converter
Currency rates are based on various publicly available sources and should be used as guidelines only. Rates are not verified as accurate, and actual rates may vary. Currency quotes are not updated every day. Check the date on the currency converter feature for the day that currency was last updated. The information supplied by this application is believed to be accurate, but the GoGolf, LP. Companies, the GoGolf, LP. Affiliates, and/or our respective suppliers do not warrant or guarantee such accuracy. When using this information for any financial purpose, we advise you to consult a qualified professional to verify the accuracy of the currency rates. We do not authorize the use of this information for any purpose other than your personal use and you are expressly prohibited from the resale, redistribution, and use of this information for commercial purposes.
Copyright and Trademark Notices
All contents of this website are copyrighted © 2012 UDIG dba GOGOLF, LP. All rights reserved.UDIG dba GOGOLF, LP is not responsible for content on websites operated by parties other than UDIG dba GOGOLF, LP, and the GoGolf and slogan "Gotta Sell It" Gotta Have It" are trademarks or registered trademarks in the U.S. and/or other countries of UDIG dba GOGOLF, LPa subsidiary of GoGolf, LP. Other product and company names mentioned herein may be the trademarks of their respective owners.
If you are aware of an infringement of our brand, please let us know by e-mailing us at info@mygogolfteetime.com.
Claims Of Copyright Infringement
1. A clear identification of the copyrighted work you claim was infringed.
2. A clear identification of the material you claim is infringing the copyrighted work, and information that will allow us to locate that material on the Website, such as a link to the infringing material.
3. Your contact information so that we can reply to your complaint, preferably including an email address and telephone number.
4. A statement that you have a "good faith belief that the material that is claimed as copyright infringement is not authorized by the copyright owner, its agent, or the law."
5. A statement that "the information in the notification is accurate, and under penalty of perjury, the complaining party is authorized to act on behalf of the owner of an exclusive right that is allegedly infringed."
6. The notice must be signed by the person authorized to act on behalf of the owner of an exclusive right that is allegedly infringed.
We will review and address all notices that comply with the requirements above..
We suggest that you consult your legal advisor before filing a notice or counter-notice. Also, be aware that you may be liable for damages if you make a false claim of copyright infringement.
General
Your use of mapping available on this Website is governed by the terms of use set forth.
This Website is operated by a U.S. entity and this Agreement is governed by the laws of the State of Texas, USA. You hereby consent to the exclusive jurisdiction and venue of courts in Bexar County, Texas, USA, in all disputes arising out of or relating to the use of this Website. Use of this Website is unauthorized in any jurisdiction that does not give effect to all provisions of these terms and conditions, including, without limitation, this paragraph.
You agree that no joint venture, partnership, or employment relationship exists between you and theUDIG dba GOGOLF, LP Companies as a result of this Agreement or use of this Website.
Our performance of this Agreement is subject to existing laws and legal process, and nothing contained in this Agreement limits our right to comply with law enforcement or other governmental or legal requests or requirements relating to your use of this Website or information provided to or gathered by us with respect to such use. To the extent allowed by applicable law, you agree that you will bring any claim or cause of action arising from or relating to your access or use of this Website within two (2) years from the date on which such claim or action arose or accrued or such claim or cause of action will be irrevocably waived.
If any part of this Agreement is determined to be invalid or unenforceable pursuant to applicable law including, but not limited to, the warranty disclaimers and liability limitations set forth above, then the invalid or unenforceable provision will be deemed superseded by a valid, enforceable provision that most closely matches the intent of the original provision and Agreement shall continue in effect.
This Agreement (and any other terms and conditions referenced herein) constitutes the entire agreement between you and GoGolf, LP. with respect to this Website and it supersedes all prior or contemporaneous communications and proposals, whether electronic, oral, or written, between the customer and GoGolf, LP.with respect to this Website. A printed version of this Agreement and of any notice given in electronic form shall be admissible in judicial or administrative proceedings based upon or relating to this Agreement to the same extent and subject to the same conditions as other business documents and records originally generated and maintained in printed form.
Fictitious names of companies, products, people, characters, and/or data mentioned on this Website are not intended to represent any real individual, company, product, or event.
Any rights not expressly granted herein are reserved.
Service Help
For quick answers to your questions or ways to contact us, visit FAQ Or, you can write to us at:
Attn: Customer Service UDIG dba GOGOLF,
GoGolf PO Box 160732 San Antonio, TX 78280
Effective as of May 10, 2012 ©2012UDIG dba GOGOLF, LP. All rights reserved.
</string>
你可以使用代码来做到这一点。因为如果在字符串中设置这些整行,则XML将不起作用,因为您需要编辑每一行。我的建议是
<TextView android:id="@+id/mylargeText"/>
在你的主要课程
TextView largeText = (TextView)findViewById(R.id.mylargeText);
在res中创建原始文件夹。然后创建名为term.txt的文件
try {
Resources res = getResources(); InputStream in_s = res.openRawResource(R.raw.term);
byte[] b = new byte[in_s.available()];
in_s.read(b);
largeText.setText(new String(b));
} catch (Exception e) {
largeText.setText("Error: can't show terms.");
}
您好,尝试以下方法
在layout.xml中创建Web视图,如terms.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget63"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<WebView
android:id="@+id/mWebView"
android:layout_width="fill_parent"
android:layout_height="410dp" />
</RelativeLayout>
然后复制你的文本,并创建一个Html文件名作为terms.html并复制资产文件夹中的html文件,然后创建一个java文件作为Terms.java复制下面的代码在其中
public class Terms extends Activity {
WebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.terms);
this.mWebView = ((WebView)findViewById(R.id.mWebView));
this.mWebView.getSettings().setBuiltInZoomControls(false);
this.mWebView.getSettings().setLoadWithOverviewMode(false);
this.mWebView.getSettings().setUseWideViewPort(false);
this.mWebView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.CLOSE);
this.mWebView.loadUrl("file:///android_asset/terms.html");
Button back_btn = (Button)findViewById(R.id.back);
back_btn.setOnClickListener(new View.OnClickListener(){
public void onClick(View view)
{
finish();
}
});
}
@SuppressWarnings("unused")
private class Callback extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return(false);
}
}
}
在Android中加载大文本最方便的方法是使用Raw Resources:
- 转到
/'YourProjectFolder'/app/src/main/res/
文件夹(路径可能不同) - 创建名为
raw
的文件夹(如果它不存在) - 将您的文本放入
.txt
文件并将其放在raw
文件夹中 - 在您的代码中将Raw Resource转换为
String
并将其设置为TextView
要获得原始资源字节(为了进一步将其转换为String
),我们需要打开InputStream
。最快(从性能的角度来看)和最安全的方式将InputStream
转换为String
(根据this answer)是使用ByteArrayOutputStream
和inputStream.read
。
为了轻松实现这一点,我写了准备使用方法:
@Nullable
private String getStringFromRawRes(int rawRes) {
InputStream inputStream;
try {
inputStream = getResources().openRawResource(rawRes);
} catch (Resources.NotFoundException e) {
e.printStackTrace();
return null;
}
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length;
try {
while ((length = inputStream.read(buffer)) != -1) {
byteArrayOutputStream.write(buffer, 0, length);
}
} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
try {
inputStream.close();
byteArrayOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
String resultString;
try {
resultString = byteArrayOutputStream.toString("UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return null;
}
return resultString;
}
像这样使用它:
String largeTextString = getStringFromRawRes(R.raw.yourLargeTextFile);
if(largeTextString != null) { //null check is optional
YourTextView.setText(largeTextString);
} else {
//something goes wrong
}
附:您可以使用标准机制轻松地为不同语言,操作系统版本,屏幕方向等覆盖此类资源。
请检查此链接有关字符串格式和样式
http://developer.android.com/guide/topics/resources/string-resource.html#FormattingAndStyling
或试试这个
<string name="terms_of_use"><![CDATA[
// copy and paste large string data
]]></string>
以上是关于在Android中加载大文本的主要内容,如果未能解决你的问题,请参考以下文章