CopyPastor

Detecting plagiarism made easy.

Score: 1.552737534046173; Reported for: String similarity, Exact paragraph match Open both answers

Possible Plagiarism

Plagiarized on 2012-08-08
by Ram kiran Pachigolla

Original Post

Original - Posted on 2011-08-03
by PiyushMishra



            
Present in both answers; Present only in the new answer; Present only in the old answer;

There are two methods 1) programatically 2) By using xml layout
1)=======>
AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(layout); builder.setTitle("Title"); alertDialog = builder.create(); alertDialog.show(); alertDialog.getWindow().setLayout(600, 400); //Controlling width and height.

( or )
alertDialog.show(); WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(alertDialog.getWindow().getAttributes()); lp.width = 150; lp.height = 500; lp.x=-170; lp.y=100; alertDialog.getWindow().setAttributes(lp);

If you want to show the layout to be displayed like `Alert dialog` see [this][1]
2)========>
choose.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/img" android:layout_width="wrap_content" android:text="@string/choose" android:textSize="25dp" android:textColor="#fff" android:layout_height="50dp"/> <TableLayout android:id="@+id/table" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#fff" android:orientation="vertical"> <TableRow android:id="@+id/tr1" android:orientation="horizontal" android:layout_margin="10dp"> <ImageView android:contentDescription="@string/phone" android:src="@drawable/phone" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <TextView android:id="@+id/phnText" android:layout_width="wrap_content" android:text="@string/phone" android:gravity="left|center_vertical" android:layout_marginLeft="10dp" android:textSize="25dp" android:textColor="#000" android:layout_height="50dp"/> </TableRow> <View android:layout_width="fill_parent" android:layout_height="1dip" android:background="#FF000000" /> <TableRow android:id="@+id/tr2" android:orientation="horizontal" android:layout_margin="10dp"> <ImageView android:contentDescription="@string/sms" android:src="@drawable/sms" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <TextView android:id="@+id/smsText" android:layout_width="wrap_content" android:text="@string/sms" android:gravity="left|center_vertical" android:layout_marginLeft="10dp" android:textSize="25dp" android:textColor="#000" android:layout_height="50dp"/> </TableRow> </TableLayout> </LinearLayout>
display this as popup as like below
private void showPopUp() { final AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this); helpBuilder.setTitle(""); LayoutInflater inflater = getLayoutInflater(); final View checkboxLayout = inflater.inflate(R.layout.choose, null); helpBuilder.setView(checkboxLayout); final AlertDialog helpDialog = helpBuilder.create(); helpDialog.show(); TableRow tablerowPhone = (TableRow)checkboxLayout.findViewById(R.id.tr1); TableRow tablerowSms = (TableRow)checkboxLayout.findViewById(R.id.tr2); tablerowPhone.setOnClickListener(new OnClickListener() { public void onClick(View v) { helpDialog.dismiss(); Uri callUri = Uri.parse("tel:" + listview_array[4]); Intent intent = new Intent(Intent.ACTION_CALL, callUri); startActivity(intent); } }); tablerowSms.setOnClickListener(new OnClickListener() { public void onClick(View v) { helpDialog.dismiss(); Uri smsUri = Uri.parse("sms:" + listview_array[4]); Intent intent = new Intent(Intent.ACTION_VIEW, smsUri); startActivity(intent); } }); }
call this `showPopUp()` method where you want. so that you can set height and width to the layout in xml file
[1]: http://blog.stylingandroid.com/archives/271
Only a slight change in Sat Code, set the layout after `show()` method of `AlertDialog`.
AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(layout); builder.setTitle("Title"); alertDialog = builder.create(); alertDialog.show(); alertDialog.getWindow().setLayout(600, 400); //Controlling width and height.
Or you can do it in my way.
alertDialog.show(); WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(alertDialog.getWindow().getAttributes()); lp.width = 150; lp.height = 500; lp.x=-170; lp.y=100; alertDialog.getWindow().setAttributes(lp);

        
Present in both answers; Present only in the new answer; Present only in the old answer;