بروز خطا
[message]
اشتراک در سوال
رای ها
[dataList]
خواندن متن در وب ویو بدون کد HTML هنگام اشتراک گذاری
من یه برنامه ساختم و مطالبش رو از سرور میگیره و قسمت متن هاش از وب ویو استفاده کردم که بشه عکس و متن رو با هم نشون بدم...
حالا بالای هر مطلب یه دکمه اشتراک گذاری گزاشتم که می خوام فقط متن وب ویو رو به اشتراک بزارن ... دکمه کار میکنه ولی تمام متن همراه با کد HTML رو هم به اشتراک میزاره .. حالا من می خوام وقتی رو دکمه اشتراک گذاری زدن فقط متن های وب یو اشتراک بزاره و کاری به کد های HTML نداشته باشه ... یعنی همینجور که نمایش میده همینجورهم به اشتراک بزاره ...
ممنون میشم اگه راهنمایی کنید.
برای این سوال 3 پاسخ وجود دارد.
پاسخ به سوال
محمد حسین زاده
12 سال پیش
+6
0
public String stripHtml(String html) {
return Html.fromHtml(html).toString();
}
پاسخ به سوال
dani
12 سال پیش
0
0
سلام ممنون از راهنماییتون ولی هر کاری کردم نشد
این کد صفحه ای هست که دکمه اشتراک گذاری توشه دقیقا کجا باید بزارم
package ir.starqeshm.starqeshm;
import java.io.File;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
public class StarNewsDetails extends EnhancedActivity {
private TextView txtName;
private TextView textother;
private ImageView imgLogo;
private Button btnShare;
private TextView texttarikh;
private TextView TextSenderName;
private TextView txtInstalls;
private TextView TextDescription;
private TextView TextPhoneNumber;
private TextView TextEmail;
private WebView webview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.star_news_details);
txtName = (TextView) findViewById(R.id.textName);
textother = (TextView) findViewById(R.id.textother);
TextSenderName = (TextView) findViewById(R.id.TextSenderName);
imgLogo = (ImageView) findViewById(R.id.imgLogo);
btnShare = (Button) findViewById(R.id.btnShare);
texttarikh = (TextView) findViewById(R.id.texttarikh);
webview = (WebView) this.findViewById(R.id.webview);
TextPhoneNumber = (TextView) findViewById(R.id.TextPhoneNumber);
TextEmail = (TextView) findViewById(R.id.TextEmail);
webview.getSettings().setAppCacheEnabled(true);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setBuiltInZoomControls(true);
txtName.setText(G.selectedApplication.name);
textother.setText(G.selectedApplication.other);
TextSenderName.setText(getString(R.string.starqeshm_4_SenderName) + " " + G.selectedApplication.SenderName);
texttarikh.setText(getString(R.string.starqeshm_4_tarikh) + " " + G.selectedApplication.tarikh);
webview.loadDataWithBaseURL("", G.selectedApplication.description, "text/html", "UTF-8", "");
TextPhoneNumber.setText(getString(R.string.starqeshm_4_phone_number) + " " + G.selectedApplication.phoneNumber);
TextEmail.setText(getString(R.string.starqeshm_4_email) + " " + G.selectedApplication.email);
Button btnShare = (Button) findViewById(R.id.btnShare);
btnShare.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent i = new Intent();
i.setAction(android.content.Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_TEXT, txtName.getText().toString() + "\n" + G.selectedApplication.description + "\n" + TextSenderName.getText().toString() + "\n" + TextEmail.getText().toString() + "\n" + TextPhoneNumber.getText().toString() + "\n" + texttarikh.getText().toString());
i.putExtra(android.content.Intent.EXTRA_SUBJECT, "ستاره قشم");
arg0.getContext().startActivity(i.createChooser(i, "به اشتراک بگذارید"));
}
});
String filename = HelperString.getFileName(G.selectedApplication.logoUrl);
final File imageFile = new File(G.DIR_FINAL + "/" + filename);
if ( !imageFile.exists()) {
imgLogo.setImageBitmap(null);
DownloadManager.addToDownloadList(G.selectedApplication.logoUrl, imgLogo);
}
BitmapFactory.Options options = new BitmapFactory.Options();
//options.inSampleSize = 8;
Bitmap bitmap = BitmapFactory.decodeFile(imageFile.getAbsolutePath(), options);
imgLogo.setImageBitmap(bitmap);
}
//options.inSampleSize = 8;
private float convertKBtoMB(long value) {
return (float) (value / 1024);
}
/**
* start downloading snapshots
*/
}
پاسخ به سوال
محمد حسین زاده
12 سال پیش
+3
0
تنها تغییری که باید بدی تو نحوه بدست آوردن رشته ای هستش که میخوای به اشتراک بذاریش
یعنی محتویات متد کلیک btnShare :
btnShare.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
String shareContent = txtName.getText().toString() + "\n" +
G.selectedApplication.description + "\n" +
G.selectedApplication.name + "\n" +
G.selectedApplication.email + "\n" +
G.selectedApplication.phoneNumber + "\n" +
G.selectedApplication.tarikh;
shareContent= Html.fromHtml(shareContent).toString();
Intent i = new Intent();
i.setAction(android.content.Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_TEXT, shareContent);
i.putExtra(android.content.Intent.EXTRA_SUBJECT, "ستاره قشم");
arg0.getContext().startActivity(i.createChooser(i, "به اشتراک بگذارید"));
}
});
پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .