Reputation: 7144
I'm trying to set right gravity to a linear layout in the OnPreExecute method, but the dialog still shows my hebrew text in the left side. What is the problem with my code ?
private ProgressDialog dialog;
private Context context;
private LinearLayout layout;
public MyTask(Activity activity) {
context = activity;
dialog = new ProgressDialog(context);
layout = new LinearLayout(context);
}
protected void onPreExecute() {
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(-1, -2);
layout.setGravity(Gravity.RIGHT);
TextView loadMsg = new TextView(context);
loadMsg.setText("טוען...");
loadMsg.setGravity(Gravity.RIGHT);
layout.addView(loadMsg, params);
dialog.setView(layout);
// dialog.setContentView(R.layout.loaddialog);
// dialog.show();
}
Upvotes: 0
Views: 8822
Reputation: 3966
I have tried to fix your problem try to use it. It is working for me.
LinearLayout lp = new LinearLayout(getApplicationContext());
lp.setMinimumWidth(100);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.setGravity(Gravity.RIGHT);
TextView loadMsg = new TextView(this);
loadMsg.setText("my msg");
loadMsg.setTextColor(Color.WHITE);
loadMsg.setGravity(Gravity.RIGHT);
lp.addView(loadMsg, params);
Dialog dialog = new Dialog(this);
dialog.setContentView(lp);
dialog.show();
Upvotes: 2