i want to set the height of alertdialoq.builder for my application.any one have any idea plz suggest me.
my problem is as follows
in my application i have four images initially as
watch publish updates extras
when i click on any of the image then the menu is display from x=0 and y=0
i want to set that menu below image
plz anyone suggest answer
because today is my deadline
here is my code
Using java Syntax Highlighting
- /*****************************************************************************
- * @File Name : MainScreen.java
- *
- * @Author : Yatish and Hitesh
- *
- * @Date : Date(04/28/2008)
- *
- * @Description : This File Provide implementation of MainScreen.
- *
- *
- * @Copyright : 2008, Umundo Corporation
- ************************************************************************/
- package com.umundo.screen;
- /** Importing umundo api */
- import java.io.InputStream;
- import java.net.URL;
- import java.util.ArrayList;
- import java.util.Hashtable;
- import java.util.Vector;
- import org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection;
- import android.app.AlertDialog;
- import android.app.ListActivity;
- import android.app.ProgressDialog;
- import android.app.AlertDialog.Builder;
- import android.content.Context;
- import android.content.DialogInterface;
- import android.content.Intent;
- import android.content.DialogInterface.OnClickListener;
- import android.graphics.Bitmap;
- import android.graphics.BitmapFactory;
- import android.os.Bundle;
- import android.os.Handler;
- import android.util.Log;
- import android.view.KeyEvent;
- import android.view.View;
- import android.view.ViewGroup;
- import android.view.View.OnFocusChangeListener;
- import android.widget.AdapterView;
- import android.widget.BaseAdapter;
- import android.widget.Gallery;
- import android.widget.GridView;
- import android.widget.ImageButton;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- import android.widget.ListAdapter;
- import android.widget.ListView;
- import android.widget.AdapterView.OnItemClickListener;
- import com.google.common.graphics.ImageUtil;
- import com.mframework.net.NetworkListener;
- import com.umundo.controller.StateManager;
- import com.umundo.model.ChannelData;
- import com.umundo.net.XmlRpcThread;
- /**
- *
- * @Yatish And Hitesh
- */
- public class MainScreen extends ListActivity implements OnItemClickListener, OnClickListener,NetworkListener, android.view.View.OnClickListener, OnFocusChangeListener
- {
- /** Called when the activity is first created. */
- public Builder watch_AD,publish_AD,extras_AD;
- public int state ;
- public ChannelData objChannelData;
- public LinearLayout layout;
- public ArrayList<ChannelList> channelList;
- public Object param1[];
- public Object[] params;
- public Intent i;
- public Bitmap image = null;
- public ChannelAdapter channelAdapter ;
- public ProgressDialog myProgressDialog = null;
- public ImageView watch,publish,updates,extras;
- public int type ;
- @Override
- public void onCreate(Bundle icicle)
- {
- super.onCreate(icicle);
- setContentView(R.layout.mainui);
- watch =(ImageView) findViewById(R.id.watch_id);
- publish =(ImageView)findViewById(R.id.publish_id);
- updates = (ImageView)findViewById(R.id.updates_id);
- extras= (ImageView)findViewById(R.id.extras_id);
- channelList = new ArrayList<ChannelList>();
- myProgressDialog = new ProgressDialog(this);
- i = new Intent (this,SearchScreen.class);
- getListView().setOnItemClickListener(this);
- watch.setOnFocusChangeListener(this);
- publish.setOnFocusChangeListener(this);
- updates.setOnFocusChangeListener(this);
- extras.setOnFocusChangeListener(this);
- watch.setOnClickListener(this);
- publish.setOnClickListener(this);
- updates.setOnClickListener(this);
- extras.setOnClickListener(this);
- }
- public void onFocusChanged(View view, boolean bool)
- {
- if(view == watch && bool == true)
- {
- watch.setImageResource(R.drawable.watch_icon_sel);
- Log.i("inside focus","<<<<<<<<"+view.toString()+" "+bool);
- }
- else
- {
- watch.setImageResource(R.drawable.watch_icon);
- }
- if(view == publish && bool == true)
- {
- publish.setImageResource(R.drawable.publish_icon_sel);
- }
- else
- {
- publish.setImageResource(R.drawable.publish_icon);
- }
- if(view == updates && bool == true)
- {
- updates.setImageResource(R.drawable.update_icon_sel);
- }
- else
- {
- updates.setImageResource(R.drawable.updates_icon);
- }
- if(view == extras && bool == true)
- {
- extras.setImageResource(R.drawable.extra_icon_sel);
- }
- else
- {
- extras.setImageResource(R.drawable.extras);
- }
- }
- /********************************************************
- * @Function Name : onItemClick
- *
- * @description : To handle all item click events on current screen.
- *
- *
- * @param view View To hold different state.
- *
- *
- * @param arg0 AdapterView
- *
- * @param arg1 View
- *
- * @param arg2 int
- *
- * @param arg3 long
- *
- * @return void
- *
- * @author Yatish And Hitesh
- *
- * @date 28 April, 2008
- *
- **********************************************************/
- public void onItemClick(AdapterView arg0, View view, int arg2, long arg3)
- {
- /* if (view instanceof android.widget.ImageView)
- {
- showMenu(arg2);
- }*/
- if(view instanceof com.umundo.screen.ChannelListView)
- {
- Log.i("Inside On ItemClick "," =="+view.toString());
- }
- }
- /********************************************************
- * @Function Name : showMenu
- *
- * @description : To handle popup menu of current screen.
- *
- *
- * @param arg int To hold different state.
- *
- * @return void
- *
- * @author Yatish And Hitesh
- *
- * @date 28 April, 2008
- *
- **********************************************************/
- public void showMenu(int arg)
- {
- switch(arg)
- {
- case StateManager.STATE_WATCH_ITEM:
- state = StateManager.STATE_WATCH_ITEM ;
- watch_AD= new AlertDialog.Builder(MainScreen.this);
- watch_AD.setIcon(R.drawable.star_m);
- watch_AD.setTitle(R.string.title1);
- watch_AD.setItems(R.array.menu_of_watch,this).show();
- break;
- case StateManager.STATE_PUBLISH_ITEM:
- state = StateManager.STATE_PUBLISH_ITEM;
- publish_AD= new AlertDialog.Builder(MainScreen.this);
- publish_AD.setIcon(R.drawable.star_m);
- publish_AD.setTitle(R.string.title2);
- publish_AD.setItems(R.array.menu_of_publish,this).show();
- break;
- case StateManager.STATE_MYUPDATE_ITEM:
- state = StateManager.STATE_MYUPDATE_ITEM;
- Log.i("Selection","myUpdates");
- break;
- case StateManager.STATE_EXTRAS_ITEM:
- state = StateManager.STATE_EXTRAS_ITEM;
- Log.i("Selection","Exteras");
- publish_AD= new AlertDialog.Builder(MainScreen.this);
- publish_AD.setIcon(R.drawable.star_m);
- publish_AD.setTitle(R.string.title3);
- publish_AD.setItems(R.array.menu_of_Extras,this).show();
- break;
- }
- }
- /********************************************************
- * @Function Name : onClick
- *
- * @description : To handle all button pressed events on current screen.
- *
- *
- * @param arg0 DailoqInterface To hold different state.
- *
- * @param arg1 int
- *
- * @return void
- *
- * @author Yatish And Hitesh
- *
- * @date 28 April, 2008
- *
- **********************************************************/
- public void onClick(DialogInterface arg0, int arg1)
- {
- Log.i("ONCLICK","arg1 "+arg1);
- switch(state)
- {
- case StateManager.STATE_WATCH_ITEM:
- switch(arg1)
- {
- case 0:
- objChannelData = new ChannelData(this);
- param1 = new Object[1];
- param1[0]="all";
- //to get public channels by filter and order
- Object[] params = new Object[4];
- params[0] = "all";
- params[1] = "recent";
- params[2] = new Integer(0);
- params[3] = new Integer(10);
- objChannelData.getFirstPage(XmlRpcThread.SERVER_REQUEST_TOTAL_PUBLIC_CHANNEL,
- XmlRpcThread.SERVER_REQUEST_CHANNEL_GET_PUBLIC_CHANNEL,param1,params,2,3);
- myProgressDialog = ProgressDialog.show(this,"","Please wait while loading...",true);
- break;
- case 1:
- objChannelData = new ChannelData(this);
- param1=new Object[1];
- param1[0]="all" ;
- //to get public channels by filter and order
- params = new Object[4];
- params[0] = "all";
- params[1] = "top_rated";
- params[2] = new Integer(0);
- params[3] = new Integer(0);
- objChannelData.getFirstPage(XmlRpcThread.SERVER_REQUEST_TOTAL_PUBLIC_CHANNEL,
- XmlRpcThread.SERVER_REQUEST_CHANNEL_GET_PUBLIC_CHANNEL,param1,params,2,3);
- myProgressDialog = ProgressDialog.show(this,"","Please wait while loading...",true);
- break;
- case 2:
- objChannelData = new ChannelData(this);
- param1=new Object[1];
- param1[0]="all" ;
- //to get public channels by filter and order
- params = new Object[4];
- params[0] = "all";
- params[1] = "most_viewed";
- params[2] = new Integer(0);
- params[3] = new Integer(0);
- objChannelData.getFirstPage(XmlRpcThread.SERVER_REQUEST_TOTAL_PUBLIC_CHANNEL,
- XmlRpcThread.SERVER_REQUEST_CHANNEL_GET_PUBLIC_CHANNEL,param1,params,2,3);
- myProgressDialog = ProgressDialog.show(this,"","Please wait while loading...",true);
- break;
- case 3:
- objChannelData = new ChannelData(this);
- param1=new Object[1];
- param1[0]="all" ;
- //to get public channels by filter and order
- params = new Object[4];
- params[0] = "featured";
- params[1] = "recent";
- params[2] = new Integer(0);
- params[3] = new Integer(0);
- objChannelData.getFirstPage(XmlRpcThread.SERVER_REQUEST_TOTAL_PUBLIC_CHANNEL,
- XmlRpcThread.SERVER_REQUEST_CHANNEL_GET_PUBLIC_CHANNEL,param1,params,2,3);
- myProgressDialog = ProgressDialog.show(this,"","Please wait while loading...",true);
- Log.i("Inside Watch ","select 4");
- break;
- case 4:
- Log.i("Inside Watch ","select 5");
- break;
- case 5:
- Log.i("Inside Watch ","select 6");
- break;
- case 6:
- Intent categories = new Intent(this,ChannelCategories.class);
- startActivity(categories);
- break;
- case 7:
- startActivity(i);
- break ;
- }
- break;
- case StateManager.STATE_PUBLISH_ITEM:
- switch(arg1)
- {
- case 0:
- Log.i("Inside Publish ","select 1");
- break;
- case 1:
- Log.i("Inside Publish ","select 2");
- break;
- case 2:
- Log.i("Inside Publish ","select 3");
- break;
- case 3:
- Intent memIntent = new Intent(this,MemmoryVideo.class);
- startActivity(memIntent);
- break;
- }
- break;
- case StateManager.STATE_MYUPDATE_ITEM:
- break;
- case StateManager.STATE_EXTRAS_ITEM:
- switch(arg1)
- {
- case 0:
- Intent channelIntent = new Intent(this,CreateChannel.class);
- startActivity(channelIntent);
- break;
- case 1:
- Intent tellIntent = new Intent(this,TellurFriend.class);
- startActivity(tellIntent);
- break;
- case 2:
- Intent changePassIntent = new Intent(this,ChangePassword.class);
- startActivity(changePassIntent);
- break;
- case 3:
- break;
- case 4:
- Intent helpIntent = new Intent(this,HelpScreen.class);
- startActivity(helpIntent);
- break;
- }
- break;
- }
- }
- public void onDataTransferFromXMLRpc(int type, Object result)
- {
- switch(type)
- {
- case XmlRpcThread.SERVER_REQUEST_CHANNEL_GET_PUBLIC_CHANNEL:
- Vector vect = (Vector)result;
- Hashtable hash[]=new Hashtable[vect.size()];
- Log.i("Log "," ");
- String strURL = null;
- for(int i= 0;i<vect.size();i++)
- {
- hash[i] = (Hashtable) vect.elementAt(i);
- strURL = (String)(hash[i].get("thumbnailUrl"));
- String title = hash[i].get("title").toString();
- String viewCount = hash[i].get("viewCount").toString();
- ChannelList c = new ChannelList(title,viewCount,strURL);
- channelList.add(c);
- }
- drawList();
- break;
- }
- }
- public void onError(int type, Hashtable hashTable)
- {
- if(myProgressDialog != null)
- myProgressDialog.dismiss();
- }
- public void onError(int type, String error)
- {
- if(myProgressDialog != null)
- myProgressDialog.dismiss();
- }
- public void onError( String error)
- {
- if(myProgressDialog != null)
- myProgressDialog.dismiss();
- }
- public void stopAnimation()
- {
- // TODO Auto-generated method stub
- }
- public void drawList()
- {
- MainScreen.this.runOnUIThread(new Runnable()
- {
- public void run()
- {
- try
- {
- channelAdapter = new ChannelAdapter(MainScreen.this,channelList);
- MainScreen.this.setListAdapter( channelAdapter );
- Log.i("layout is adeed by this view"," iiiiiiiiiiiii");
- }
- catch(Exception e)
- {
- Log.i(" Inside the catch Block ", " excdeption "+ e.toString());
- }
- myProgressDialog.dismiss();
- }
- });
- }
- /********************************************************
- * @Function Name : downLoadImage
- *
- * @description : To create image from remote location
- *
- * @param type String Its define the type of function which has been called to get data.
- *
- * @return void
- *
- * @author Yatish And Hitesh
- *
- * @date 01 April, 2008
- *
- **********************************************************/
- /*public Bitmap downLoadImage(String url_String)
- {
- Log.i("Download manager","iN SIDE METHOD");
- URL url = null;
- Bitmap bitmap = null;
- try
- {
- url = new URL(url_String);
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setDoInput(true);
- connection.connect();
- InputStream is = connection.getInputStream();
- bitmap = BitmapFactory.decodeStream(is);
- is.close();
- connection.disconnect();
- return bitmap;
- }
- catch(Exception exception)
- {
- Log.i("in side the exception download manager"," "+exception.toString());
- }
- return null;
- }*/
- /*public boolean onKeyDown(int keyCode, KeyEvent event)
- {
- Log.i(" the key code of the pressed buttton "," == "+keyCode);
- if(keyCode == KeyEvent.KEYCODE_BACK )
- {
- this.onDestroy();
- return true;
- }
- return true;
- }
- */
- protected void onDestroy()
- {
- Log.i(" onDestryed "," == ");
- super.onDestroy();
- this.finish();
- System.exit(0);
- }
- public void onClick(View view)
- {
- if(view == watch)
- {
- showMenu(0);
- }
- else if(view == publish)
- {
- showMenu(1);
- }
- else if(view == updates)
- {
- showMenu(2);
- }
- else if (view == extras)
- {
- Log.i("<<<<<<<<<<<<<<<","iside"+view);
- showMenu(3);
- }
- }
- }
Parsed in 0.087 seconds, using GeSHi 1.0.8.4




