我在Android应用程序上使用Twitter4j Library。有没有办法使用用户可以编辑推文文本的高音扬声器对话框进行推文?我不想以编程方式发推文,例如facebook dialogs。
答案 0 :(得分:0)
This is URL to tweet directly to twitter
http://twitter.com/share?text=" + shareDescription + "&url=http://" + shareURL
Add below code where you want to call tweet action
`enter code here`
ProgressDialog progressDialog = new ProgressDialog(getActivity());
TwitterShare d = new TwitterShare(getActivity(), progressDialog,
"http://twitter.com/share?text=" + shareDescription
+ "&url=http://" + shareURL);
d.show();
progressDialog.setMessage("Loading...");
progressDialog.setCancelable(true);
progressDialog.show();
create one class add below code to that class.This class opens the webview and it redirect to particular URL
enter code here
public class TwitterShare extends Dialog {
ProgressDialog progress;
String shareURL;
ImageView close;
public TwitterShare(Context context, ProgressDialog progress,
String shareURL) {
super(context);
this.progress = progress;
this.shareURL = shareURL;
// TODO Auto-generated constructor stub
}
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);// must call before super.
super.onCreate(savedInstanceState);
setContentView(R.layout.ln_dialog);
close = (ImageView) findViewById(R.id.close_button);
WebView mWebView = (WebView) findViewById(R.id.webkitWebView1);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(shareURL);
mWebView.setWebViewClient(new HelloWebViewClient());
mWebView.setPictureListener(new PictureListener() {
@Override
public void onNewPicture(WebView view, Picture picture) {
if (progress != null && progress.isShowing()) {
progress.dismiss();
}
}
});
close.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
TwitterShare.this.cancel();
}
});
}
class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.i("url", url);
view.loadUrl(url);
return true;
}
}
}
Layout file for Webview
enter code here
<?xml version="1.0" encoding="utf-``8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="300dip"
android:layout_height="480dip"
android:orientation="vertical" >
<WebView
android:id="@+id/webkitWebView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<ImageView
android:id="@+id/close_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"`enter code here`
android:src="@drawable/close_button" />
</RelativeLayout>