Search Results

Search found 641 results on 26 pages for 'imageview'.

Page 14/26 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Draw and move animation from xml in android

    - by Muahammad Yousuf Saif
    What I want to do: I want to draw image from xml and then animate it from xml. this image should move with constant speed anywhere on our screen. Now the problem is: I can draw and animate image from xml but i can not move this image with constant speed. I am using two xml files: One for animate and other for moving. XML for animation: android:duration="200"/ XML file for move: <translate android:interpolator="@android:anim/linear_interpolator" android:fromXDelta="2%" android:toXDelta="400%" android:fromYDelta="2%" android:toYDelta="800%"/> Activity.java file code in onCreate() method: ImageView rocketImage = (ImageView) findViewById(R.id.rocket_image); Animation hyperspaceJump = AnimationUtils.loadAnimation(this, R.anim.hyperspace_jump); rocketImage.setBackgroundResource(R.drawable.rocket_thrust); AnimationDrawable rocketAnimation = (AnimationDrawable) rocketImage.getBackground(); rocketAnimation.start(); rocketImage.startAnimation(hyperspaceJump);

    Read the article

  • Android Expandable List View Update

    - by Gaurav Arora
    I am implementing a chatting application, where I have made a service to listen all the presence changed. On the change of the presence I want to update the data and I am unable to update the data that is showing in the expandable list view. Please suggest me a means to do the same. public class UserMenuActivity extends ExpandableListActivity { private XMPPConnection connection; String name,availability,subscriptionStatus; TextView tv_Status; /** Variable Define here */ private String[] data = { "View my profile", "New Multiperson Chat", "New Broad Cast Message", "New Contact Category", "New Group", "Invite to CCM", "Search", "Expand All", "Settings", "Help", "Close" }; private String[] data_Contact = { "Rename Category","Move Contact to Category", "View my profile", "New Multiperson Chat", "New Broad Cast Message", "New Contact Category", "New Group", "Invite to CCM", "Search", "Expand All", "Settings", "Help", "Close" }; private String[] data_child_contact = { "Open chat", "Delete Contact","View my profile", "New Multiperson Chat", "New Broad Cast Message", "New Contact Category", "New Group", "Invite to CCM", "Search", "Expand All", "Settings", "Help", "Close" }; private String[] menuItem = { "Chats", "Contacts", "CGM Groups", "Pending","Request" }; private List<String> menuItemList = Arrays.asList(menuItem); private int commonGroupPosition = 0; private String etAlertVal; private DatabaseHelper dbHelper; private int categoryID, listPos; /** New Code here.. */ private ArrayList<String> groupNames; private ArrayList<ArrayList<ChildItems>> childs; private UserMenuAdapter adapter; private Object object; private String[] data2 = { "PIN Michelle", "IP Call" }; private ListView mlist2; private ImageButton mimBtnMenu; private LinearLayout mllpopmenu; private View popupView; private PopupWindow popupWindow; private AlertDialog.Builder alert; private EditText input; private TextView mtvUserName, mtvUserTagLine; private ExpandableListView mExpandableListView; public static List<CategoryDataClass> categoryList; private boolean menuType = false; private String childValContact=""; public static Context context; @Override public void onBackPressed() { if (mllpopmenu.getVisibility() == View.VISIBLE) { mllpopmenu.setVisibility(View.INVISIBLE); } else { if (CCMStaticVariable.CommonConnection.isConnected()) { CCMStaticVariable.CommonConnection.disconnect(); } super.onBackPressed(); } } @SuppressWarnings("unchecked") @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_MENU) { if (mllpopmenu.getVisibility() == View.VISIBLE) { mllpopmenu.setVisibility(View.INVISIBLE); } else { if (commonGroupPosition >= 4 && menuType == true) { if(childValContact == ""){ mllpopmenu.setVisibility(View.VISIBLE); mlist2.setAdapter(new ArrayAdapter(UserMenuActivity.this, R.layout.listviewtext, R.id.tvMenuText, data_Contact)); }else{ mllpopmenu.setVisibility(View.VISIBLE); mlist2.setAdapter(new ArrayAdapter(UserMenuActivity.this, R.layout.listviewtext, R.id.tvMenuText, data_child_contact)); } } else if (commonGroupPosition == 0) { mllpopmenu.setVisibility(View.VISIBLE); mlist2.setAdapter(new ArrayAdapter(UserMenuActivity.this, R.layout.listviewtext, R.id.tvMenuText, data)); } } return true; } return super.onKeyDown(keyCode, event); } @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.usermenulayout); dbHelper = new DatabaseHelper(UserMenuActivity.this); //this.context = context.getApplicationContext(); XMPPConn.getContactList(); connection = CCMStaticVariable.CommonConnection; Presence userPresence = new Presence(Presence.Type.available); userPresence.setPriority(24); userPresence.setMode(Presence.Mode.away); connection.sendPacket(userPresence); } @Override protected void onResume() { super.onResume(); Presence userPresence = new Presence(Presence.Type.available); userPresence.setPriority(24); userPresence.setMode(Presence.Mode.away); connection.sendPacket(userPresence); XMPPConn.getContactList(); setExpandableListView(); } public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { if (groupPosition == 1 && childPosition == 0) { startActivity(new Intent(UserMenuActivity.this, InvitetoCCMActivity.class)); } else if (groupPosition == 1 && childPosition != 0) { Intent intent = new Intent(UserMenuActivity.this, UserChatActivity.class); intent.putExtra("userNameVal", XMPPConn.mfriendList.get(childPosition - 1).friendName); startActivity(intent); } else if (groupPosition == 2 && childPosition == 0) { startActivity(new Intent(UserMenuActivity.this, CreateGroupActivity.class)); } else if (groupPosition == 2 && childPosition != 0) { String GROUP_NAME = childs.get(groupPosition).get(childPosition) .getName().toString(); int end = GROUP_NAME.indexOf("("); CCMStaticVariable.groupName = GROUP_NAME.substring(0, end).trim(); startActivity(new Intent(UserMenuActivity.this, GroupsActivity.class)); } else if (groupPosition >= 4) { childValContact = childs.get(groupPosition).get(childPosition).getName().trim(); showToast("user==>"+childValContact, 0); } return false; } private void setExpandableListView() { /***###############GROUP ARRAY ############################*/ final ArrayList<String> groupNames = new ArrayList<String>(); groupNames.add("Chats (2)"); groupNames.add("Contacts (" + XMPPConn.mfriendList.size() + ")"); groupNames.add("CGM Groups (" + XMPPConn.mGroupList.size() + ")"); groupNames.add("Pending (1)"); XMPPConn.getGroup(); categoryList = dbHelper.getAllCategory(); /**Group From Sever*/ if (XMPPConn.mGroupList.size() > 0) { for (int g = 0; g < XMPPConn.mGroupList.size(); g++) { XMPPConn.getGroupContact(XMPPConn.mGroupList.get(g).groupName); groupNames.add(XMPPConn.mGroupList.get(g).groupName + "(" + XMPPConn.mGroupContactList.size()+ ")"); } } if(categoryList.size() > 0){ for (int cat = 0; cat < categoryList.size(); cat++) { groupNames.add(categoryList.get(cat).getCategoryName()+ "(0)"); } } this.groupNames = groupNames; /*** ###########CHILD ARRAY * #################*/ ArrayList<ArrayList<ChildItems>> childs = new ArrayList<ArrayList<ChildItems>>(); ArrayList<ChildItems> child = new ArrayList<ChildItems>(); child.add(new ChildItems("Alisha", "Hi",0)); child.add(new ChildItems("Michelle", "Good Morning",0)); childs.add(child); child = new ArrayList<ChildItems>(); child.add(new ChildItems("", "",0)); if (XMPPConn.mfriendList.size() > 0) { for (int n = 0; n < XMPPConn.mfriendList.size(); n++) { child.add(new ChildItems(XMPPConn.mfriendList.get(n).friendNickName, XMPPConn.mfriendList.get(n).friendStatus, XMPPConn.mfriendList.get(n).friendState)); } } childs.add(child); /************** CGM Group Child here *********************/ child = new ArrayList<ChildItems>(); child.add(new ChildItems("", "",0)); if (XMPPConn.mGroupList.size() > 0) { for (int grop = 0; grop < XMPPConn.mGroupList.size(); grop++) { child.add(new ChildItems( XMPPConn.mGroupList.get(grop).groupName + " (" + XMPPConn.mGroupList.get(grop).groupUserCount + ")", "",0)); } } childs.add(child); child = new ArrayList<ChildItems>(); child.add(new ChildItems("Shuchi", "Pending (Waiting for Authorization)",0)); childs.add(child); /************************ Group Contact List *************************/ if (XMPPConn.mGroupList.size() > 0) { for (int g = 0; g < XMPPConn.mGroupList.size(); g++) { /** Contact List */ XMPPConn.getGroupContact(XMPPConn.mGroupList.get(g).groupName); child = new ArrayList<ChildItems>(); for (int con = 0; con < XMPPConn.mGroupContactList.size(); con++) { child.add(new ChildItems( XMPPConn.mGroupContactList.get(con).friendName, XMPPConn.mGroupContactList.get(con).friendStatus,0)); } childs.add(child); } } if(categoryList.size() > 0){ for (int cat = 0; cat < categoryList.size(); cat++) { child = new ArrayList<ChildItems>(); child.add(new ChildItems("-none-", "",0)); childs.add(child); } } this.childs = childs; /** Set Adapter here */ adapter = new UserMenuAdapter(this, groupNames, childs); setListAdapter(adapter); object = this; mlist2 = (ListView) findViewById(R.id.list2); mimBtnMenu = (ImageButton) findViewById(R.id.imBtnMenu); mllpopmenu = (LinearLayout) findViewById(R.id.llpopmenu); mtvUserName = (TextView) findViewById(R.id.tvUserName); mtvUserTagLine = (TextView) findViewById(R.id.tvUserTagLine); //Set User name.. System.out.println("CCMStaticVariable.loginUserName===" + CCMStaticVariable.loginUserName); if (!CCMStaticVariable.loginUserName.equalsIgnoreCase("")) { mtvUserName.setText("" + CCMStaticVariable.loginUserName); } /** Expandable List set here.. */ mExpandableListView = (ExpandableListView) this .findViewById(android.R.id.list); mExpandableListView.setOnGroupClickListener(new OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { XMPPConn.getContactList(); if (parent.isGroupExpanded(groupPosition)) { commonGroupPosition = 0; }else{ commonGroupPosition = groupPosition; } String GROUP_NAME = groupNames.get(groupPosition); int end = groupNames.get(groupPosition).indexOf("("); String GROUP_NAME_VALUE = GROUP_NAME.substring(0, end).trim(); if (menuItemList.contains(GROUP_NAME_VALUE)) { menuType = false; CCMStaticVariable.groupCatName = GROUP_NAME_VALUE; } else { menuType = true; CCMStaticVariable.groupCatName = GROUP_NAME_VALUE; } long findCatId = dbHelper.getCategoryID(GROUP_NAME_VALUE); if (findCatId != 0) { categoryID = (int) findCatId; } childValContact=""; showToast("Clicked on==" + GROUP_NAME_VALUE, 0); return false; } }); /** Click on item */ mlist2.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int pos,long arg3) { if (commonGroupPosition >= 4) { if(childValContact == ""){ if (pos == 0) { showAlertEdit(CCMStaticVariable.groupCatName); } /** Move contact to catgory */ if (pos == 1) { startActivity(new Intent(UserMenuActivity.this,AddContactCategoryActivity.class)); } }else{ if(pos == 0){ Intent intent = new Intent(UserMenuActivity.this,UserChatActivity.class); intent.putExtra("userNameVal",childValContact); startActivity(intent); } if(pos == 1){ XMPPConn.removeEntry(childValContact); showToast("Contact deleted sucessfully", 0); Intent intent = new Intent(UserMenuActivity.this,UserMenuActivity.class); } } } else { /** MyProfile */ if (pos == 0) { startActivity(new Intent(UserMenuActivity.this, MyProfileActivity.class)); } /** New multiperson chat start */ if (pos == 1) { startActivity(new Intent(UserMenuActivity.this, NewMultipersonChatActivity.class)); } /** New Broadcast message */ if (pos == 2) { startActivity(new Intent(UserMenuActivity.this, NewBroadcastMessageActivity.class)); } /** Click on add category */ if (pos == 3) { showAlertAdd(); } if (pos == 4) { startActivity(new Intent(UserMenuActivity.this, CreateGroupActivity.class)); } if (pos == 5) { startActivity(new Intent(UserMenuActivity.this, InvitetoCCMActivity.class)); } if (pos == 6) { startActivity(new Intent(UserMenuActivity.this, SearchActivity.class)); } if (pos == 7) { onGroupExpand(2); for (int i = 0; i < groupNames.size(); i++) { mExpandableListView.expandGroup(i); } } /** Click on settings */ if (pos == 8) { startActivity(new Intent(UserMenuActivity.this, SettingsActivity.class)); } if (pos == 10) { System.exit(0); } if (pos == 14) { if (mllpopmenu.getVisibility() == View.VISIBLE) { mllpopmenu.setVisibility(View.INVISIBLE); if (popupWindow.isShowing()) { popupWindow.dismiss(); } } else { mllpopmenu.setVisibility(View.VISIBLE); mlist2.setAdapter(new ArrayAdapter( UserMenuActivity.this, R.layout.listviewtext, R.id.tvMenuText, data)); } } } } }); } /** Toast message display here.. */ private void showToast(String msg, int time) { Toast.makeText(this, msg, time).show(); } public String showSubscriptionStatus(String friend){ return friend; } } Service.class public class UpdaterService extends Service { private XMPPConnection connection; String Friend; String user = ""; @Override public IBinder onBind(Intent arg0) { // TODO Auto-generated method stub return null; } @Override public void onCreate() { // Toast.makeText(this, "My Service Created", Toast.LENGTH_LONG).show(); super.onCreate(); } @Override public void onDestroy() { // TODO Auto-generated method stub super.onDestroy(); } @Override public void onStart(Intent intent, int startId) { // TODO Auto-generated method stub showToast("My Service Started", 0); connection = getConnection(); if (connection.isConnected()) { final Roster roster = connection.getRoster(); RosterListener r1 = new RosterListener() { @Override public void presenceChanged(Presence presence) { // TODO Auto-generated method stub XMPPConn.getContactList(); } @Override public void entriesUpdated(Collection<String> arg0) { // TODO Auto-generated method stub //notification("entriesUpdated"); } @Override public void entriesDeleted(Collection<String> arg0) { // TODO Auto-generated method stub //notification("entriesDeleted"); } @Override public void entriesAdded(Collection<String> arg0) { // TODO Auto-generated method stub Iterator<String> it = arg0.iterator(); if (it.hasNext()) { user = it.next(); } RosterEntry entry = roster.getEntry(user); if(entry.getType().toString().equalsIgnoreCase("to")){ int index_of_Alpha = Friend.indexOf("@"); String subID = Friend.substring(0, index_of_Alpha); notification("Hi "+subID+" wants to add you"); } } }; if (roster != null) { roster.setSubscriptionMode(Roster.SubscriptionMode.manual); System.out.println("subscription going on"); roster.addRosterListener(r1); } } else { showToast("Connection lost-", 0); } } protected void showToast(String msg, int time) { Toast.makeText(this, msg, time).show(); } private XMPPConnection getConnection() { return CCMStaticVariable.CommonConnection; } /** Notification manager */ private void notification(CharSequence message) { String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); int icon = R.drawable.ic_launcher; CharSequence tickerText = message; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); Context context = getApplicationContext(); CharSequence contentTitle = "CCM"; CharSequence contentText = message; Intent notificationIntent = new Intent(this, ManageNotification.class); notificationIntent.putExtra("Subscriber_ID",user ); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); notification.flags |= Notification.FLAG_AUTO_CANCEL; final int HELLO_ID = 1; mNotificationManager.notify(HELLO_ID, notification); } } Here is my adapter class public class UserMenuAdapter extends BaseExpandableListAdapter { private ArrayList<String> groups; private ArrayList<ArrayList<ChildItems>> childs; private Context context; public LayoutInflater inflater; ImageView img_availabiliy; private static final int[] EMPTY_STATE_SET = {}; private static final int[] GROUP_EXPANDED_STATE_SET = {android.R.attr.state_expanded}; private static final int[][] GROUP_STATE_SETS = { EMPTY_STATE_SET, // 0 GROUP_EXPANDED_STATE_SET // 1 }; public UserMenuAdapter(Context context, ArrayList<String> groups, ArrayList<ArrayList<ChildItems>> childs) { this.context = context; this.groups = groups; this.childs = childs; inflater = LayoutInflater.from(context); } @Override public Object getChild(int groupPosition, int childPosition) { return childs.get(groupPosition).get(childPosition); } @Override public long getChildId(int groupPosition, int childPosition) { return (long) (groupPosition * 1024 + childPosition); } @Override public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { View v = null; if (convertView != null) v = convertView; else v = inflater.inflate(R.layout.child_layout, parent, false); ChildItems ci = (ChildItems) getChild(groupPosition, childPosition); TextView tv = (TextView) v.findViewById(R.id.tvChild); tv.setText(ci.getName()); TextView tv2 = (TextView) v.findViewById(R.id.tvChild2); tv2.setText(ci.getDailyStatus()); img_availabiliy = (ImageView)v.findViewById(R.id.img_childlayout_AVAILABILITY); ImageView friendPics = (ImageView)v.findViewById(R.id.ivFriendPics); if(ci.getStatusState() == 1){ img_availabiliy.setImageResource(R.drawable.online); } else if(ci.getStatusState()==0){ img_availabiliy.setImageResource(R.drawable.offline); } else if (ci.getStatusState()==2) { img_availabiliy.setImageResource(R.drawable.away); } else if(ci.getStatusState()==3){ img_availabiliy.setImageResource(R.drawable.busy); } else{ img_availabiliy.setImageDrawable(null); } if((groupPosition == 1 && childPosition == 0)){ friendPics.setImageResource(R.drawable.inviteto_ccm); img_availabiliy.setVisibility(View.INVISIBLE); } else if(groupPosition == 2 && childPosition == 0){ friendPics.setImageResource(R.drawable.new_ccmgroup); img_availabiliy.setVisibility(View.VISIBLE); }else{ if(ci.getPicture()!= null){ Bitmap bitmap = BitmapFactory.decodeByteArray(ci.getPicture(), 0, ci.getPicture().length); bitmap = Bitmap.createScaledBitmap(bitmap, 50, 50, true); friendPics.setImageBitmap(bitmap); }else{ friendPics.setImageResource(R.drawable.avatar); } img_availabiliy.setVisibility(View.VISIBLE); } return v; } @Override public int getChildrenCount(int groupPosition) { return childs.get(groupPosition).size(); } @Override public Object getGroup(int groupPosition) { return groups.get(groupPosition); } @Override public int getGroupCount() { return groups.size(); } @Override public long getGroupId(int groupPosition) { return (long) (groupPosition * 1024); } @Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { View v = null; if (convertView != null) v = convertView; else v = inflater.inflate(R.layout.group_layout, parent, false); String gt = (String) getGroup(groupPosition); TextView tv2 = (TextView) v.findViewById(R.id.tvGroup); if (gt != null) tv2.setText(gt); /**Set Image on group layout, Max/min*/ View ind = v.findViewById( R.id.explist_indicator); View groupInd = v.findViewById( R.id.llgroup); if( ind != null ) { ImageView indicator = (ImageView)ind; if( getChildrenCount( groupPosition ) == 0 ) { indicator.setVisibility( View.INVISIBLE ); } else { indicator.setVisibility( View.VISIBLE ); int stateSetIndex = ( isExpanded ? 1 : 0) ; Drawable drawable = indicator.getDrawable(); drawable.setState(GROUP_STATE_SETS[stateSetIndex]); } } if( groupInd != null ) { RelativeLayout indicator2 = (RelativeLayout)groupInd; if( getChildrenCount( groupPosition ) == 0 ) { indicator2.setVisibility( View.INVISIBLE ); } else { indicator2.setVisibility( View.VISIBLE ); int stateSetIndex = ( isExpanded ? 1 : 0) ; Drawable drawable2 = indicator2.getBackground(); drawable2.setState(GROUP_STATE_SETS[stateSetIndex]); } } return v; } @Override public boolean hasStableIds() { return true; } @Override public boolean isChildSelectable(int groupPosition, int childPosition) { return true; } public void onGroupCollapsed(int groupPosition) { } public void onGroupExpanded(int groupPosition) { } } I just want to update my list in ON PRESENCE CHANGED method in the Service class.. Please suggest me a means to do the same.

    Read the article

  • frame by frame animation not running

    - by abc
    well,i am a newbie to android..and i dont know whats wrong in my code.. this is my xml file <?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" id="selected" android:oneshot="false"> <item android:drawable="@drawable/w1" android:duration="50" /> <item android:drawable="@drawable/w2" android:duration="50" /> </animation-list> my java file ImageView img = (ImageView)findViewById(R.id.s); img.setBackgroundResource(R.anim.shape_animation); // Get the background, which has been compiled to an AnimationDrawable object. AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground(); // Start the animation (looped playback by default). frameAnimation.start();

    Read the article

  • Maintaining last stage when rotating through CATransform3DIdentity

    - by Mikhail Naimy
    Hi. i am rotating imageview through following code.it rotates fine..but when i rotate again , Imageview goes to previous angle( which is in initial stage) and then it rotates...any one can help in this?rotationTransform has been declared as CABasicAnimation* rotationAnimation in .h file.... - (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event { UITouch *touch = [touches anyObject]; startTouchPosition = [touch locationInView:self.view]; } - (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event { UITouch *touch = [[event allTouches] anyObject]; location = [touch locationInView:self.view]; currentLocationRadians = atan2f(location.y - self.view.frame.size.height/2, location.x - self.view.frame.size.width/2); lastLocationRadians = atan2f(startTouchPosition.y - self.view.frame.size.height/2, startTouchPosition.x - self.view.frame.size.width/2); rotationTransform = CATransform3DIdentity; rotationTransform = CATransform3DRotate(rotationTransform, currentLocationRadians-lastLocationRadians + rad, 0.0, 0.0, 1.0); _imgview.layer.transform = rotationTransform; } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { rotationTransform = _imgview.layer.transform; }

    Read the article

  • Show image from url in uiimageview

    - by skiria
    I try to show a image in my iphone app but it doesn't show. I connect in IB and I check to show a local image, it workd good. I also check the url from image and it is ok. I use the next code: NSURL *imageURL = [NSURL URLWithString: aVideo.urlThumbnail]; NSData *imageData = [NSData dataWithContentsOfURL:imageURL]; UIImage *image = [UIImage imageWithData:imageData]; imageView.image = image; and //Video.h NSString *urlThumbnail; and this is my code on the view. - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [tableView reloadData]; } - (void)viewDidLoad { [super viewDidLoad]; NSURL *imageURL = [NSURL URLWithString: aVideo.urlThumbnail]; NSData *imageData = [NSData dataWithContentsOfURL:imageURL]; UIImage *image = [UIImage imageWithData:imageData]; imageView.image = image; }

    Read the article

  • Objective - C, fastest way to show sequence of images in UIImageView

    - by Almas Adilbek
    I have hundreds of images, which are frame images of one animation (24 images per second). Each image size is 1024x690. My problem is, I need to make smooth animation iterating each image frame in UIImageView. I know I can use animationImages of UIImageView. But it crashes, because of memory problem. Also, I can use imageView.image = [UIImage imageNamed:@""] that would cache each image, so that the next repeat animation will be smooth. But, caching a lot of images crashed app. Now I use imageView.image = [UIImage imageWithContentsOfFile:@""], which does not crash app, but doesn't make animation so smooth. Maybe there is a better way to make good animation of frame images? Maybe I need to make some preparations, in order to somehow achieve better result. I need your advices. Thank you!

    Read the article

  • how to display complete Bitmap in android using Canvas?

    - by UMMA
    friends, i am using following onDraw method to display bitmap on screen. @Override public void onDraw(Canvas canvas) { Bitmap _scratch = BitmapFactory.decodeResource(getResources(), R.drawable.icon2); //ImageView img= new ImageView(Tutorial2D.this); //img.setImageBitmap(_scratch); canvas.drawColor(Color.BLACK); canvas.drawBitmap(_scratch, 0, 0, null); } image is displayed on the screen but some part because android screen is small how can i display complete image in whole android screen? can i set ScaleType of image to fitxy in canvas ? or can i add android layout image to this canvas so that i could set fitxy property or image there as i have commented the code? any help would be appreciated.

    Read the article

  • Show transparent color filter on a View after clicking it

    - by Maarten
    So. You know how when you click a post in the Google+ app, the entire View becomes blue. I want to do that as well, but with an ImageView. I have the following code snippet, setting the actual image as the background and the selector as the main resource. This looks good, but doesn't respect scaleType for the background image: <ImageView android:id="@+id/painting_image" android:layout_width="match_parent" android:layout_height="200dp" android:background="@drawable/img" android:src="@drawable/selector" android:scaleType="centerCrop" /> By the way, @drawable/selector is just a selector that shows a tranparent color for state_pressed: <item android:state_pressed="true"> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#44521400" /> </shape></item> How can I make this work while respecting the scaleType?

    Read the article

  • image is not getting loaded in view.

    - by anurag
    I have created 2 views named "FirstView" and "SecondView".SecondView's nib file has an UIImage view object as its IBOtlet.Now I am getting an UIImage object from some FirstViewController's method.Now I am setting the SecondViewController's imageView property with that image and then I am pushing my SecondView Controller's object in Navigation Controller.The SecondView gets loaded but that image is not shown in that view. The code is as follows:..... - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo { [[picker parentViewController] dismissModalViewControllerAnimated:YES]; SecondViewController *secondView=[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:[NSBundle mainBundle]]; secondView.imageView.image=img; [self.navigationController pushViewController:secondView animated:YES]; }

    Read the article

  • image is not getting loaded in view.

    - by anurag
    I have created 2 views named "FirstView" and "SecondView".SecondView's nib file has an UIImage view object as its IBOtlet.Now I am getting an UIImage object from some FirstViewController's method.Now I am setting the SecondViewController's imageView property with that image and then I am pushing my SecondView Controller's object in Navigation Controller.The SecondView gets loaded but that image is not shown in that view. The code is as follows:..... (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo { [[picker parentViewController] dismissModalViewControllerAnimated:YES]; SecondViewController *secondView=[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:[NSBundle mainBundle]]; secondView.imageView.image=img; [self.navigationController pushViewController:secondView animated:YES]; }

    Read the article

  • Display the y value of a uiImageView during an animation

    - by user1422132
    I have the following code: NSString *yValue; yValue=[[NSString alloc] initWithFormat:@"%1.2f" , imageView.center.y]; CGRect labelFrame = CGRectMake( 10, 100, 200, 50 ); UILabel* label5 = [[UILabel alloc] initWithFrame: labelFrame]; [label5 setBackgroundColor:[UIColor blackColor]]; [label5 setText: yValue]; [label5 setTextColor: [UIColor orangeColor]]; [self.view addSubview: label5]; This correctly shows the y value of the UIimageView but the problem is that it only shows the ending y value. When a person flicks the UIImageView I animate it using: [UIView animateWithDuration:2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ recognizer.view.center = finalPoint; } What I want is the label5 to display the y value of the imageView during the animation not just after. Is it possible to do this?

    Read the article

  • How save image in Android Universal Image Loader?

    - by Saeed
    In Lazy List i use this code and my image store in a folder named LazyList ImageLoader imageLoader=new ImageLoader(context); imageLoader.DisplayImage(url, imageView); But in Universal Image Loader i use this ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()) .build(); ImageLoader.getInstance().init(config); img = (ImageView) this.findViewById(R.id.test_id); ImageLoader imageLoader = ImageLoader.getInstance(); imageLoader.displayImage(URL.RECIPE_IMG_URL,img); but each time it use internet to get image and didn't store my image in any folder i aslo add .diskCache(new UnlimitedDiscCache(new File("myFolder"))) to config but nothing store in myFolder.Any ideas?

    Read the article

  • Animation with CGPoint in for loop

    - by user1066524
    I'm trying to do an animation where when a person clicks from point A to Point B on screen the object should slowly slide straight across (horizontally) from point A to Point B. I tried doing a for loop with something like: for (CGFloat i=previousPoint.x; i <= newPoint.x; i++){ [UIView animateWithDuration:10 delay:0 options:nil animations:^ { [magnifier removeFromSuperview]; magnifier = [[MagnifierView alloc] init]; CGPoint np = {i, newPoint.y}; magnifier.viewToMagnify = imageView; magnifier.touchPoint = np; [imageView addSubview:magnifier]; [magnifier setNeedsDisplay]; } completion:^(BOOL finished) { }]; } but for some reason it is moving it way up and then eventually to point B. sort of in a weird curve. how can I do this correctly?

    Read the article

  • How to check if Contact has Image?

    - by Pentium10
    I am assigning to an ImageView contacts images using this code: mPhotoView = (ImageView) findViewById(R.id.photo); mPhotoView.setImageURI(objItem.getPhotoUri()); If the contact has no image, this does nothing, and no error is raised. When there is no image, I want to add a default image. So I need to check either if the image was added to the view, or check that the URI holds some image data How do I achieve that? Than I will set default image by this: mPhotoView.setImageResource(R.drawable.ic_contact_picture_2);

    Read the article

  • Android camera to take multiple photos

    - by user2975407
    problem.java public class problem extends Activity { ImageView iv; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.problem); iv=(ImageView) findViewById(R.id.imageView1); Button b=(Button) findViewById(R.id.button1); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent=new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, 0); } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); Bitmap bm=(Bitmap) data.getExtras().get("data"); iv.setImageBitmap(bm); } } From this code I can only take one photo and it displayed in the screen. **But I want to take more photos nearly 5 photos and display in the screen** Further I want to add these photos to MySQL database.please help me to do that.I am new to android

    Read the article

  • Android - Custom Adapter Problem

    - by Ryan
    Hello, I seem to be having a problem with my Custom Adapter view. When I display the list, it only displays a white screen. Here is how it works: 1.) I send a JSON request 2.) populate the ArrayList with the returned results 3.) create a custom adapter 4.) then bind the adapter. Here is steps 2-4 private void updateUI() { ListView myList = (ListView) findViewById(android.R.id.list); itemList = new ArrayList(); Iterator it = data.entrySet().iterator(); while (it.hasNext()) { //Get the key name and value for it Map.Entry pair = (Map.Entry)it.next(); String keyName = (String) pair.getKey(); String value = pair.getValue().toString(); if (value != null) { ListItem li = new ListItem(keyName, value, false); itemList.add(li); } } CustomAdapter mAdapter = new CustomAdapter( mContext, itemList); myList.setAdapter(mAdapter); //Bind the adapter to the list //Tell the dialog it's cool now. dismissDialog(0); //Show next screen flipper.setInAnimation(inFromRightAnimation()); flipper.setOutAnimation(outToRightAnimation()); flipper.showNext(); } And here is my CustomAdapter class: import java.util.List; import android.R.color; import android.content.Context; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; class MyAdapterView extends RelativeLayout { public MyAdapterView(Context c, ListItem li) { super( c ); RelativeLayout rL = new RelativeLayout(c); RelativeLayout.LayoutParams containerParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); rL.setLayoutParams(containerParams); rL.setBackgroundColor(color.white); ImageView img = new ImageView (c); img.setImageResource(li.getImage()); img.setPadding(5, 5, 10, 5); rL.addView(img, 48, 48); TextView top = new TextView(c); top.setText(li.getTopText()); top.setTextColor(color.black); top.setTextSize(20); top.setPadding(0, 20, 0, 0); rL.addView(top,ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); TextView bot = new TextView( c ); bot.setText(li.getBottomText()); bot.setTextColor(color.black); bot.setTextSize(12); bot.setPadding(0, 0, 0, 10); bot.setAutoLinkMask(1); rL.addView(bot,ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); } } public class CustomAdapter extends BaseAdapter { private Context context; private List itemList; public CustomAdapter(Context c, List itemL ) { this.context = c; this.itemList = itemL; } public int getCount() { return itemList.size(); } public Object getItem(int position) { return itemList.get(position); } public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { ListItem li = itemList.get(position); return new MyAdapterView(this.context, li); } } Does anyone have any idea why this displays a white screen upon completion?? Thanks in advance!

    Read the article

  • ScrollView in android

    - by rantravee
    hi, I' have a view that contains several textViews an ImageView and a Button . Because on small screen devices (or in landscape mode on big ones ) not all are visible I use a Scroll as the parent of the whole hierarchy to allow the user to view all the information. The things are suck that the button must be at the buttom of the view . However on big screen device , where it remains enough space at the buttom , the button is put immediatelly below the last textview,and seems to occupy all the remaining space (resulting in an unnactractive view) . Trying to use android:allignParentButtom ="true" not only that it has no effect but it puts the button at top of the screen . Has anyone any ideea how could I accomplish what I described ? here's the xml <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/scroll_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true"> <RelativeLayout android:id="@+id/gps_info_page1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_centerHorizontal="true"> <TextView android:id="@+id/itsDateTimeValue" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:text="@string/eStrUnknown"> </TextView> <RelativeLayout android:id="@+id/directions" android:layout_centerHorizontal="true" android:layout_below="@+id/itsDateTimeValue" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:id="@+id/itsDirectionValue" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="0" android:layout_marginRight="2dip" android:textSize="20sp"> </TextView> <TextView android:id="@+id/itsOrientation" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20sp" android:layout_marginLeft="2dip" android:text="@string/eStrUnknown" android:layout_toRightOf="@+id/itsDirectionValue"> </TextView> </RelativeLayout> <ImageView android:id="@+id/itsImage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/compass" android:layout_below="@+id/directions" android:layout_centerHorizontal="true"> </ImageView> <RelativeLayout> ..."TextViews below the above image" </RelativeLayout> <RelativeLayout> ..."TextViews below the above" </RelativeLayout> <RelativeLayout> ..."TextViews below the above" </RelativeLayout> <RelativeLayout> ..."TextViews below the above" </RelativeLayout> <RelativeLayout ..."TextViews below the above" </RelativeLayout> <LinearLayout android:id="@+id/div" android:layout_width="fill_parent" android:layout_height="1dip" android:layout_below="@+id/sunset_layout" android:background="#F333"> </LinearLayout> <Button //adding here android:alignParentBottom="true" has described above behavior android:layout_marginBottom="3dip" android:layout_marginTop="20dip" android:id="@+id/done_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/eStrDone" android:textSize="18sp" android:layout_below="@+id/div" android:layout_centerHorizontal="true"> </Button> </RelativeLayout> </ScrollView>

    Read the article

  • TabHost / TabWidget - Scale Background Image ?

    - by user359519
    I need to scale my TabWidget background images so they maintain aspect ratio. I am using a TabHost with a TabWidget. I am then using setBackgroundDrawable to set the images. I found a close answer here - Background in tab widget ignore scaling. However, I'm not sure just where to add the new Drawable code. (Working with the HelloTabWidget example, none of my modules use RelativeLayout, and I don't see any layout for "tabcontent".) I also found this thread - Android: Scale a Drawable or background image?. According to it, it sounds like I would have to pre-scale my images, which defeats the whole purpose of making them scaleable. I also found another thread where someone subclassed the Drawable class so it would either not scale, or it would scale properly. I can't find it now, but that seems like a LOT to go through when you should just be able to do something simple like mTab.setScaleType(centerInside). Here's my code: main.xml: <?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/main_background"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"/> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0"/> </LinearLayout> </TabHost> main activity: tabHost.setOnTabChangedListener(new OnTabChangeListener() { TabHost changedTabHost = getTabHost(); TabWidget changedTabWidget = getTabWidget(); View changedView = changedTabHost.getTabWidget().getChildAt(0); public void onTabChanged(String tabId) { int selectedTab = changedTabHost.getCurrentTab(); TabWidget tw = getTabWidget(); if(selectedTab == 0) { //setTitle("Missions Timeline"); View tempView = tabHost.getTabWidget().getChildAt(0); tempView.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_timeline_on)); tempView = tabHost.getTabWidget().getChildAt(1); tempView.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_map_off)); tempView = tabHost.getTabWidget().getChildAt(2); tempView.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_search_off)); tempView = tabHost.getTabWidget().getChildAt(3); tempView.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_news_off)); tempView = tabHost.getTabWidget().getChildAt(4); tempView.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_license_off)); //ImageView iv = (ImageView)tabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.icon); //iv.setImageDrawable(getResources().getDrawable(R.drawable.tab_timeline_on)); //iv = (ImageView)tabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.icon); //iv.setImageDrawable(getResources().getDrawable(R.drawable.tab_map_off)); } else if (selectedTab == 1) { //setTitle("Spinoffs Around You"); View tempView = tabHost.getTabWidget().getChildAt(0); tempView.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_timeline_off)); tempView = tabHost.getTabWidget().getChildAt(1); tempView.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_map_on)); tempView = tabHost.getTabWidget().getChildAt(2); tempView.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_search_off)); tempView = tabHost.getTabWidget().getChildAt(3); tempView.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_news_off)); tempView = tabHost.getTabWidget().getChildAt(4); tempView.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_license_off)); } I also tried 9patch images, but they wind up being too small. So, what's the best way to go about this?

    Read the article

  • Android: Use XML Layout for List Cell rather than Java Code Layout (Widgets)

    - by Stephen Finucane
    Hi, I'm in the process of making a music app and I'm currently working on the library functionality. I'm having some problems, however, in working with a list view (In particular, the cells). I'm trying to move from a simple textview layout in each cell that's created within java to one that uses an XML file for layout (Hence keeping the Java file mostly semantic) This is my original code for the cell layout: public View getView(int position, View convertView, ViewGroup parent) { String id = null; TextView tv = new TextView(mContext.getApplicationContext()); if (convertView == null) { music_column_index = musiccursor.getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE); musiccursor.moveToPosition(position); id = musiccursor.getString(music_column_index); music_column_index = musiccursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DISPLAY_NAME); musiccursor.moveToPosition(position); id += "\n" + musiccursor.getString(music_column_index); music_column_index = musiccursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM); musiccursor.moveToPosition(position); id += "\n" + musiccursor.getString(music_column_index); tv.setText(id); } else tv = (TextView) convertView; return tv; } And my new version: public View getView(int position, View convertView, ViewGroup parent) { View cellLayout = findViewById(R.id.albums_list_cell); ImageView album_art = (ImageView) findViewById(R.id.album_cover); TextView album_title = (TextView) findViewById(R.id.album_title); TextView artist_title = (TextView) findViewById(R.id.artist_title); if (convertView == null) { music_column_index = musiccursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM); musiccursor.moveToPosition(position); album_title.setText(musiccursor.getString(music_column_index)); //music_column_index = musiccursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DISPLAY_NAME); //musiccursor.moveToPosition(position); music_column_index = musiccursor.getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE); musiccursor.moveToPosition(position); artist_title.setText(musiccursor.getString(music_column_index)); } else{ cellLayout = (TextView) convertView; } return cellLayout; } The initialisation (done in the on create file): musiclist = (ListView) findViewById(R.id.PhoneMusicList); musiclist.setAdapter(new MusicAdapter(this)); musiclist.setOnItemClickListener(musicgridlistener); And the respective XML files: (main) <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ListView android:id="@+id/PhoneMusicList" android:layout_width="fill_parent" android:layout_height="fill_parent" /> <TextView android:id="@android:id/empty" android:layout_width="wrap_content" android:layout_height="0dip" android:layout_weight="1.0" android:text="@string/no_list_data" /> </LinearLayout> (albums_list_cell) <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/albums_list_cell" android:layout_width="wrap_content" android:layout_height="wrap_content"> <ImageView android:id="@+id/album_cover" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_width="50dip" android:layout_height="50dip" /> <TextView android:id="@+id/album_title" android:layout_toRightOf="@+id/album_cover" android:layout_alignParentTop="true" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/artist_title" android:layout_toRightOf="@+id/album_cover" android:layout_below="@+id/album_title" android:layout_width="wrap_content" android:layout_height="15dip" /> </RelativeLayout> In theory (based on the tiny bit of Android I've done so far) this should work..it doesn't though. Logcat gives me a null pointer exception at line 96 of the faulty code, which is the album_title.setText line. It could be a problem with my casting but Google tells me this is ok :D Thanks for any help and let me know if you need more info!

    Read the article

  • CustomListAdapter Problem in Android? Getting ClassCast Exception? How???

    - by Praveen Chandrasekaran
    i want to improve the list view's performance. this is the code for my getView method in my Adapter? public View getView(int arg0, View text_view_name, ViewGroup parent) { try { if (text_view_name == null) { text_view_name = mInflater.inflate( R.layout.bs_content_list_item1, null); text_view_name.setTag(R.id.text1_detail1, text_view_name .findViewById(R.id.text1_detail1)); text_view_name.setTag(R.id.text3_detail1, text_view_name .findViewById(R.id.text3_detail1)); text_view_name.setTag(R.id.eve_img_detail1, text_view_name .findViewById(R.id.eve_img_detail1)); } text1 = (TextView) text_view_name.getTag(R.id.text1_detail1); // text2 = (TextView) text_view_name.getTag(R.id.text2); text3 = (TextView) text_view_name.getTag(R.id.text3_detail1); img = (ImageView) text_view_name.getTag(R.id.eve_img_detail1); text1.setText(VAL1[arg0]); text3.setText(VAL3[arg0]); if (!mBusy) { img_value = new URL(VAL4[arg0]); mIcon11 = BitmapFactory.decodeStream(img_value.openConnection() .getInputStream()); img.setImageBitmap(mIcon11); text_view_name.setTag(R.id.eve_img_detail1, null); } else { img.setImageResource(R.drawable.icon); text_view_name.setTag(R.id.eve_img_detail1, text_view_name .findViewById(R.id.eve_img_detail1)); } } catch (Exception e) { name = "Exception in MultiLine_bar_details1 getView"; Log.v(TAG, name + e); } return text_view_name; } this is the code for scrollstatechanged method: public void onScrollStateChanged(AbsListView view, int scrollState) { switch (scrollState) { case OnScrollListener.SCROLL_STATE_IDLE: try { MultiLine_bar_details1.mBusy = false; int first = view.getFirstVisiblePosition(); int count = view.getCount(); for (int i = 0; i < count; i++) { ImageView t = (ImageView) view.getChildAt(i);// here getting the ClassCastException if (t.getTag(R.id.eve_img_detail1) != null) { MultiLine_bar_details1.img_value = new URL( MultiLine_bar_details1.VAL4[first + i]); MultiLine_bar_details1.mIcon11 = BitmapFactory .decodeStream(MultiLine_bar_details1.img_value .openConnection().getInputStream()); MultiLine_bar_details1.img.setImageBitmap(MultiLine_bar_details1.mIcon11); t.setTag(R.id.eve_img_detail1, null); } } } catch (Exception e) { Log.v(TAG, "Idle" + e); } // mStatus.setText("Idle"); break; case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL: MultiLine_bar_details1.mBusy = true; break; case OnScrollListener.SCROLL_STATE_FLING: MultiLine_bar_details1.mBusy = true; break; } } getting the Exception in Idle state: 05-03 16:47:15.201: VERBOSE/BS_Bars(258): Idlejava.lang.ClassCastException: android.widget.LinearLayout this is very complicated for me to get the output properly. actually i have the listview with custom adapter. that icons makes the listview scroll very slow.i am getting the images for icons from the image urls. upto this(above code) i can improve the scroll performance of my list view. but the image icons are not proper in the corresponding order. its dynamically changing when i scroll the listview.. i refered the commonsware busy coder guide and this blog. My very Big question is "How can we access the single view in scrollstatechanged parameter AbsListView? " what is the problem in it? how to do it better? Any Idea?

    Read the article

  • Select Multiple Images Using GalleryView

    - by hwrdprkns
    Hi guys, I was just wondering if Android had built in code so that I could select multiple images in a gallery-view and then have those images exported as filenames in a string array(ex /sdcard/~f1.jpg, /sdcard/~f2.jpg,...). I have the gallery code here, but I'm not sure what modifications need to be made. Any help is appreciated. Thanks! // take_picture = (Button)findViewById(R.id.take_picture); // Here we set up a string array of the thumbnail ID column we want to // get back String[] proj = { MediaStore.Images.Thumbnails._ID }; if(proj.length == 0) { nopic.setVisibility(View.VISIBLE); } // Now we create the cursor pointing to the external thumbnail store cursor = managedQuery( MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, proj, // Which // columns // to // return null, // WHERE clause; which rows to return (all rows) null, // WHERE clause selection arguments (none) null); // Order-by clause (ascending by name) /* take_picture.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent i = new Intent(GalleryActivity.this, CameraActivity.class); startActivity(i); } }); */ // We now get the column index of the thumbnail id column_index = cursor .getColumnIndexOrThrow(MediaStore.Images.Thumbnails._ID); // Reference the Gallery view g = (Gallery) findViewById(R.id.gallery); if(proj.length == 0) { nopic.setVisibility(View.VISIBLE); g.setVisibility(View.GONE); } // Set the adapter to our custom adapter (below) g.setAdapter(new ImageAdapter(this)); // Set a item click listener, and just Toast the clicked position g.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { // Now we want to actually get the data location of the file String[] proj = { MediaStore.Images.Media.DATA }; // We request our cursor again cursor = managedQuery( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, proj, // Which // columns // to // return null, // WHERE clause; which rows to return (all rows) null, // WHERE clause selection arguments (none) null); // Order-by clause (ascending by name) // We want to get the column index for the data uri column_index = cursor .getColumnIndexOrThrow(MediaStore.Images.Media.DATA); // Lets move to the selected item in the cursor cursor.moveToPosition((int) g.getSelectedItemId()); // And here we get the filename String filename = cursor.getString(column_index); Log.v("GalleryActivity", filename); Toast.makeText(GalleryActivity.this, filename, Toast.LENGTH_SHORT).show(); setPrefs(filename); Intent i = new Intent(GalleryActivity.this, OtherClass.class); startActivity(i); } }); } And the ImageAdapter code here: public class ImageAdapter extends BaseAdapter { int mGalleryItemBackground; public ImageAdapter(Context c) { mContext = c; // See res/values/attrs.xml for the that defines // Gallery1. TypedArray a = obtainStyledAttributes(R.styleable.Gallery); mGalleryItemBackground = a.getResourceId( R.styleable.Gallery_android_galleryItemBackground, 0); a.recycle(); } public int getCount() { return cursor.getCount(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { ImageView i = new ImageView(mContext); if (convertView == null) { cursor.moveToPosition(position); int id = cursor.getInt(column_index); i.setImageURI(Uri.withAppendedPath( MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, "" + id)); i.setScaleType(ImageView.ScaleType.FIT_XY); i.setLayoutParams(new Gallery.LayoutParams(200, 200)); // The preferred Gallery item background i.setBackgroundResource(mGalleryItemBackground); } return i; } } Again any help is appreciateds! Just to let you guys know, the gallery works fine (for one image) as in it exports the filename correctly. Just need to know if there is an easy way to select multiples and export them. Thanks again!

    Read the article

  • CustomListAdapter Problem in Android? How???

    - by Praveen Chandrasekaran
    i want to improve the list view's performance. this is the code for my getView method in my Adapter? public View getView(int arg0, View text_view_name, ViewGroup parent) { try { if (text_view_name == null) { text_view_name = mInflater.inflate( R.layout.bs_content_list_item1, null); text_view_name.setTag(R.id.text1_detail1, text_view_name .findViewById(R.id.text1_detail1)); text_view_name.setTag(R.id.text3_detail1, text_view_name .findViewById(R.id.text3_detail1)); text_view_name.setTag(R.id.eve_img_detail1, text_view_name .findViewById(R.id.eve_img_detail1)); } text1 = (TextView) text_view_name.getTag(R.id.text1_detail1); // text2 = (TextView) text_view_name.getTag(R.id.text2); text3 = (TextView) text_view_name.getTag(R.id.text3_detail1); img = (ImageView) text_view_name.getTag(R.id.eve_img_detail1); text1.setText(VAL1[arg0]); text3.setText(VAL3[arg0]); if (!mBusy) { img_value = new URL(VAL4[arg0]); mIcon11 = BitmapFactory.decodeStream(img_value.openConnection() .getInputStream()); img.setImageBitmap(mIcon11); text_view_name.setTag(R.id.eve_img_detail1, null); } else { img.setImageResource(R.drawable.icon); text_view_name.setTag(R.id.eve_img_detail1, text_view_name .findViewById(R.id.eve_img_detail1)); } } catch (Exception e) { name = "Exception in MultiLine_bar_details1 getView"; Log.v(TAG, name + e); } return text_view_name; } this is the code for scrollstatechanged method: public void onScrollStateChanged(AbsListView view, int scrollState) { switch (scrollState) { case OnScrollListener.SCROLL_STATE_IDLE: try { MultiLine_bar_details1.mBusy = false; int first = view.getFirstVisiblePosition(); int count = view.getCount(); for (int i = 0; i < count; i++) { ImageView t = (ImageView) view.getChildAt(i); if (t.getTag(R.id.eve_img_detail1) != null) { MultiLine_bar_details1.img_value = new URL( MultiLine_bar_details1.VAL4[first + i]); MultiLine_bar_details1.mIcon11 = BitmapFactory .decodeStream(MultiLine_bar_details1.img_value .openConnection().getInputStream()); MultiLine_bar_details1.img.setImageBitmap(MultiLine_bar_details1.mIcon11); t.setTag(R.id.eve_img_detail1, null); } } } catch (Exception e) { Log.v(TAG, "Idle" + e); } // mStatus.setText("Idle"); break; case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL: MultiLine_bar_details1.mBusy = true; break; case OnScrollListener.SCROLL_STATE_FLING: MultiLine_bar_details1.mBusy = true; break; } } this is very complicated for me to get the output properly. actually i have the listview with custom adapter. that icons makes the listview scroll very slow.i am getting the images for icons from the image urls. upto this(above code) i can improve the scroll performance of my list view. but the image icons are not proper in the corresponding order. its dynamically changing when i scroll the listview.. i refered the commonsware busy coder guide and this blog. My very Big question is "How can we access the single view in scrollstatechanged parameter AbsListView? " what is the problem in it? how to do it better? Any Idea?

    Read the article

  • add an image in listview

    - by danish
    Hi I would like to add more images in my list view as this code below only displays image 1 and 2 continuously in each row. What I want to do is display a different image for each different row. Here is mycode below; Thanks for any help. I am not good at java please change the code where necessary and I can then refer to it. public class starters extends ListActivity { private static class EfficientAdapter extends BaseAdapter { private LayoutInflater mInflater; private Bitmap mIcon1; private Bitmap mIcon2; private Bitmap mIcon3; private Bitmap mIcon4; private Bitmap mIcon5; private Bitmap mIcon6; private Bitmap mIcon7; private Bitmap mIcon8; private Bitmap mIcon9; private Bitmap mIcon10; public EfficientAdapter(Context context) { // Cache the LayoutInflate to avoid asking for a new one each time. mInflater = LayoutInflater.from(context); // Icons bound to the rows. mIcon1 = BitmapFactory.decodeResource(context.getResources(), R.drawable.starters1); mIcon2 = BitmapFactory.decodeResource(context.getResources(), R.drawable.starters2); mIcon3 = BitmapFactory.decodeResource(context.getResources(), R.drawable.starters3); mIcon4 = BitmapFactory.decodeResource(context.getResources(), R.drawable.starters4); mIcon5 = BitmapFactory.decodeResource(context.getResources(), R.drawable.starters5); mIcon6 = BitmapFactory.decodeResource(context.getResources(), R.drawable.starters6); mIcon7 = BitmapFactory.decodeResource(context.getResources(), R.drawable.starters7); mIcon8 = BitmapFactory.decodeResource(context.getResources(), R.drawable.starters8); mIcon9 = BitmapFactory.decodeResource(context.getResources(), R.drawable.starters9); mIcon10 = BitmapFactory.decodeResource(context.getResources(), R.drawable.starters10); } public int getCount() { return DATA.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { // A ViewHolder keeps references to children views to avoid unneccessary calls // to findViewById() on each row. ViewHolder holder; // When convertView is not null, we can reuse it directly, there is no need // to reinflate it. We only inflate a new View when the convertView supplied // by ListView is null. if (convertView == null) { convertView = mInflater.inflate(R.layout.starters, null); // Creates a ViewHolder and store references to the two children views // we want to bind data to. holder = new ViewHolder(); holder.text = (TextView) convertView.findViewById(R.id.text01); holder.text = (TextView) convertView.findViewById(R.id.secondLine); holder.icon = (ImageView) convertView.findViewById(R.id.icon01); convertView.setTag(holder); } else { // Get the ViewHolder back to get fast access to the TextView // and the ImageView. holder = (ViewHolder) convertView.getTag(); } // Bind the data efficiently with the holder. holder.text.setText(DATA[position]); holder.icon.setImageBitmap((position & 1) ==1 ? mIcon1 : mIcon2); return convertView; } static class ViewHolder { TextView text; ImageView icon; } } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new EfficientAdapter(this)); } private static final String[] DATA = { "Original nachos", "Toasted chicken and cheese quesadillas", "Chicken, lime and coriander nachos", "Spicy bean and cheese quesadillas", "Tuna and corn quesadillas", "Cheesy bean and sweetcorn nachos", "Crispy chicken, avocado and lime salad", "Beef and baby corn tostada", "Spicy mexican rice with chicken and prawns", "Chilli potato boats"}; }

    Read the article

  • Problem with Android Layout

    - by Ryan
    I'm having a very hard time getting the 2 buttons in the 2nd child linearlayout to display as I want them to... I want them centered on screen but they appear left-aligned. Can anyone help me with this? <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/black" android:orientation="vertical"> <LinearLayout android:id="@+id/splash" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> <ImageView android:id="@+id/imageLogo1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:adjustViewBounds="true" android:cropToPadding="true" android:scaleType="fitXY" android:src="@drawable/isi_logo" android:paddingLeft="50sp" android:paddingRight="50sp" android:paddingTop="20sp"/> <ImageView android:id="@+id/imageLogo2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:adjustViewBounds="true" android:cropToPadding="true" android:scaleType="fitXY" android:src="@drawable/sa_logo" android:paddingLeft="100sp" android:paddingRight="100sp" android:paddingBottom="20sp"/> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_gravity="center"> <Button android:id="@+id/buttonScores" android:layout_width="wrap_content" android:layout_height="wrap_content" android:width="100sp" android:text="@string/scores"/> <Button android:id="@+id/buttonStart" android:layout_width="wrap_content" android:layout_height="wrap_content" android:width="100sp" android:text="@string/test"/> </LinearLayout> </LinearLayout>

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >