Search Results

Search found 434 results on 18 pages for 'linearlayout'.

Page 12/18 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Android - Widget to Play Video (onclick trouble)

    - by Josh
    I am trying to make a simple widget that will play a movie from the sdcard when clicked on. This seems simple enough, and by following tutorials I've come up with the following code, but it seems the onclick is never setup. Manifest: <receiver android:name="WidgetProvider" android:label="DVD Cover"> <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/appwidget_info_2x4"/> </receiver> Layout (widget.xml): <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/holder" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ff777777" > <ImageView android:id="@+id/cover" android:layout_width="wrap_content" android:layout_height="fill_parent" android:textColor="#000000" /> </LinearLayout> appwidget.xml: <?xml version="1.0" encoding="utf-8"?> <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:minWidth="200dip" android:minHeight="300dip" android:updatePeriodMillis="180000" android:initialLayout="@layout/widget" > </appwidget-provider> WidgetProvider.java: public class WidgetProvider extends AppWidgetProvider { public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { String movieurl = Environment.getExternalStorageDirectory().getPath() + "/Movie.mp4"; Intent notificationIntent = new Intent(Intent.ACTION_VIEW); notificationIntent.setDataAndType(Uri.parse(movieurl), "video/*"); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent,0); // Get the layout for the App Widget and attach an on-click listener // to the button RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget); views.setOnClickPendingIntent(R.id.holder, contentIntent); // Tell the AppWidgetManager to perform an update on the current app widget appWidgetManager.updateAppWidget(appWidgetIds, views); } } Any help would be greatly appreciated. Thanks, Josh

    Read the article

  • Android: Change the source of ImageView present in ListView

    - by Vivek
    Hi All, I have a ListView specified by list_item.xml Now I need to change the Image in my list inside onListItemClick. How to achieve this? //list_item.xml <?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="wrap_content"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/play" android:id="@+id/img" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" android:id="@+id/txt" /> </LinearLayout> I have a Custom Adapter to populate my list. Code below is the adapter. public class MyCustomAdapter extends ArrayAdapter<String> { public MyCustomAdapter(Context context, int textViewResourceId, String[] objects) { super(context, textViewResourceId, objects); // TODO Auto-generated constructor stub } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub LayoutInflater inflater=getLayoutInflater(); View row=inflater.inflate(R.layout.list_item, parent, false); TextView label=(TextView)row.findViewById(R.id.txt); label.setText(Sounds[position]); ImageView icon=(ImageView)row.findViewById(R.id.img); icon.setMaxHeight(32); icon.setMaxWidth(32); icon.setPadding(2, 1, 5, 1); icon.setImageResource(R.drawable.play); return row; } } And in onCreate I do the following @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { setListAdapter(new MyCustomAdapter(this, R.layout.list_item, Sounds)); //Sounds --> String array } catch(Exception e) { e.printStackTrace(); } } Now when any row is selected, I need to change the image associated with the selected view. Your help is appreciated. Thanks.

    Read the article

  • Android - updating a list adapter creates a NullPointException

    - by GeekedOut
    I have a ListActivity which has an adapter that crashes. Here is the code that crashes the program: Question q = new Question (); q.setQuestion( "" ); questions.add(q); adapter = new ArrayAdapter<Question>(this, R.layout.user_question_list, R.id.label, questions); Here is how I create the adapter: ArrayAdapter<Question> adapter; ArrayList<Question> questions = new ArrayList <Question>( ); and the list xml is like this: <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dp" android:textSize="16sp" > </TextView> and the overall Activity xml is like this: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" > <TextView android:id="@+id/question_label" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Loading your questions..." /> <ListView android:id="@android:id/list" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@+id/label" android:textSize="20px" > </ListView> <Button android:id="@+id/add_question" android:layout_height="wrap_content" android:text="Ask a Question" android:onClick="sendFeedback" android:layout_width="fill_parent"> </Button> </LinearLayout> Any idea why the code where I try to update the adapter results in the NullPointerException? Thanks!!

    Read the article

  • How can I set drawable to a ListView in android

    - by sxingfeng
    I am writing a app for android 1.5. I want to use a complex listview to display my data. I want to show a ImageView of a drawable object in my List item. I learned from a demo: ------> listData.put("Img", listData.put("Img", R.drawable.XXX)); listData.put("Time", "100"); listItems.add(listData); It can display correctly, however, I want to change Img at runtime, The image maybe generated at run-time, so I change the code as follow, but it falls. Can anyone help me ? many thanks! protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.item_list); itemListView = (ListView) findViewById(R.id.listview); ArrayList<HashMap<String, Object>> listItems = new ArrayList<HashMap<String, Object>>(); for(int i = 0;i <XXX.size(); ++i) { HashMap<String, Object> listData = new HashMap<String, Object>(); ---------> 1) listData.put("Img", new Drawable(XXX)); 2) listData.put("Time", "100"); 3) listItems.add(listData); } SimpleAdapter listItemAdapter = new SimpleAdapter(this, listItems, R.layout.listitem, new String[] { "Img", "Time"}, new int[] { R.id.listitem_img, R.id.listitem_time }); itemListView.setAdapter(listItemAdapter); listitem.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:paddingBottom="4dip" android:paddingLeft="12dip" android:paddingRight="12dip"> <ImageView android:paddingTop="12dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/listitem_img" /> <TextView android:layout_height="wrap_content" android:textSize="20dip" android:layout_width="wrap_content" android:id="@+id/listitem_time" /> </LinearLayout>

    Read the article

  • GridView: How can I get rid of extra space from my GirdView object?

    - by Lajos Arpad
    Hello, I'm writing an application for Android phones for Human vs. Human chess play over the internet. I was looking at some tutorials, to learn how to develop Android applications and found a very nice example of making galleries (it was a GridView usage example for making a gallery about dogs) and the idea came to draw the chess table using a GridView, because the example project also handled the point & click event and I intended to use the same event in the same way, but for a different purpose. The game works well (currently it's a hotseat version), however, I'm really frustrated by the fact that whenever I rotate the screen of the phone, my GridView gets hysterical and puts some empty space in my chess table between the columns. I realized that the cause of this is that the GridView's width is the same as its parent's and the GridView tries to fill its parent in with, but there should (and probably is) be a simple solution to get rid of this problem. However, after a full day of researching, I haven't found any clue to help me to make a perfect drawing about my chess table without a negative side effect in functionality. The chess table looks fine if the phone is in Portrait mode, but in Landscape mode it's far from nice. This is how I can decide whether we are in Portrait or Landscape mode: ((((MainActivity)mContext).getWindow().getWindowManager().getDefaultDisplay().getWidth()) < ((MainActivity)mContext).getWindow().getWindowManager().getDefaultDisplay().getHeight()) In the main.xml file the GridView is defined in the following way: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gridview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:numColumns="8" android:verticalSpacing="0dp" android:horizontalSpacing="0dp" android:stretchMode="columnWidth" android:gravity="center" > </GridView> ... </LinearLayout> I appreciate any help with the problem and thank you for reading this.

    Read the article

  • Correct use of setEmtpyView in AdapterView

    - by Sebi
    I'm really having trouble using the setEmptyView method. I tried it to implement it in GridView and ListView, but both of them didnt work. Here a sample codeblock: networkGames = (GridView) baseLayer.findViewById(R.id.all_game_grid_network); networkGames.setBackgroundResource(R.drawable.game_border); networkGames.setSelector(R.drawable.game_active_border); networkGames.setOnItemClickListener(new NetworkGameListener()); networkGames.setEmptyView(View.inflate(baseLayer, R.drawable.no_network_games, null)); networkGames.setAdapter(new NetworkAdapter()); The network adapter contains no items: private class NetworkAdapter extends BaseAdapter { /* (non-Javadoc) * @see android.widget.Adapter#getCount() */ @Override public int getCount() { return 0; } /* (non-Javadoc) * @see android.widget.Adapter#getItem(int) */ @Override public Object getItem(int position) { return null; } /* (non-Javadoc) * @see android.widget.Adapter#getItemId(int) */ @Override public long getItemId(int position) { return 0; } /* (non-Javadoc) * @see android.widget.Adapter#getView(int, android.view.View, android.view.ViewGroup) */ @Override public View getView(int position, View convertView, ViewGroup parent) { return null; } } I also tried to call networkGames.setAdapter(null), but this doesnt work either. My emtpyView looks like this: <LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"> <TextView android:text="There are currently no network games available. Start a new one." android:id="@+id/TextView01" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center"> </TextView> </LinearLayout> I really don't know what I'm doing wrong. I also read various tutorials, but none of them metnioned any problems.

    Read the article

  • Android animation's first frame is applied too early on ImageView

    - by Robert
    I have the following View setup in one of my Activities: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/photoLayout" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:id="@+id/photoImageView" android:src="@drawable/backyardPhoto" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:scaleType="centerInside" android:padding="45dip" > </ImageView> </LinearLayout> Without an animation set, this displays just fine. However I want to display a very simple animation. So in my Activity's onStart override, I have the following: @Override public void onStart() { super.onStart(); mPhotoImageView = (ImageView) findViewById(R.id.photoImageView); float offset = -25; int top = mPhotoImageView.getTop(); TranslateAnimation anim1 = new TranslateAnimation( Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, top, Animation.ABSOLUTE, offset); anim1.setInterpolator(new AnticipateInterpolator()); anim1.setDuration(1500); anim1.setStartOffset(5000); TranslateAnimation anim2 = new TranslateAnimation( Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, offset, Animation.ABSOLUTE, top); anim2.setInterpolator(new BounceInterpolator()); anim2.setDuration(3500); anim2.setStartOffset(6500); mBouncingAnimation = new AnimationSet(false); mBouncingAnimation.addAnimation(anim1); mBouncingAnimation.addAnimation(anim2); mPhotoImageView.setAnimation(mBouncingAnimation); } The problem is that when the Activity displays for the first time, the initial position of the photo is not in the center of the screen with padding around. It seems like the first frame of the animation is loaded already. Only after the animation is completed, does the photoImageView "snap" back to the intended location. I've looked and looked and could not find how to avoid this problem. I want the photoImageView to start in the center of the screen, and then the animation to happen, and return it to the center of the screen. The animation should happen by itself without interaction from the user.

    Read the article

  • How do You Center a TextView in Layout?

    - by Ken
    I have a complex layout, part of which features a value centered over a label, with + and - buttons on either side of the value. I want the value to center between the buttons, whether it is "1" or "99". It looks fine when it's a 2-digit number like "99", but when it's a single digit the number is left-justified. How do I properly center that value? Here's the portion of my layout that does this: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@id/runway_label" android:layout_centerHorizontal="true" android:orientation="horizontal"> <ImageView android:id="@+id/dec_runway_button" android:src="@drawable/minus_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical"/> <TextView android:id="@+id/runway_value" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textStyle="bold" android:textSize="40.0sp" android:minWidth="50sp" android:layout_centerInParent="true" android:layout_gravity="center" android:shadowColor="#333333" android:shadowDx="2.0" android:shadowDy="2.0" android:shadowRadius="3.0" /> <ImageView android:id="@+id/inc_runway_button" android:src="@drawable/plus_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical"/> </LinearLayout>

    Read the article

  • Android - I can't make a widget clickable to launch an intent

    - by Daniele
    Hi all. I am new to Android development. I have developed a very simple widget that was meant to interact with the user via an ImageButton. What I am trying to do now is as follows. When a user taps the button (after adding the widget to their home screen), I want the phone to dial a certain telephone number. A sort of speed dial for your home screen. Unfortunately when I tap the button nothing happens. This is the body of my SpeedDialAppWidgetProvider.onUpdate method: Log.d("", "beginning of onUpdate"); final int N = appWidgetIds.length; for (int i=0; i<N; i++) { int appWidgetId = appWidgetIds[i]; Log.d("", "dealing with appWidgetId: " + appWidgetId); // Create an Intent to launch ExampleActivity Intent dialIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:1234567")); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, dialIntent, 0); Log.d("", "pendingIntent classname " + pendingIntent.getClass().getName()); // Get the layout for the App Widget and attach an on-click listener to the button RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.speed_dial_appwidget); remoteViews.setOnClickPendingIntent(R.id.dial_icon, pendingIntent); Log.d("", "remoteViews classname " + remoteViews.getClass().getName()); // Tell the AppWidgetManager to perform an update on the current App Widget appWidgetManager.updateAppWidget(appWidgetId, remoteViews); Log.d("", "end of onUpdate"); I can see the method is called and the result of the logging makes sense. The speed_dial_appwidget.xml file is like this: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" androidrientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" > <ImageButton id="@+id/dial_icon" android:src="@drawable/speed_dial" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> Can you please help me with this? Thanks in advance, Dan

    Read the article

  • Android WebView viewport

    - by alex2k8
    With html below I expected that the green rectangle would occupy only half of the screen, but on practice it occupies the whole screen width. I tried other values for viewport width, no luck. Any ideas why it does not work? Html <html> <head> <meta name="viewport" content="width=640" /> </head> <body> <div style="width: 300px; height: 50px; background: green;">300px</div> <div style="width: 600px; height: 50px; background: yellow;">600px</div> </body> </html> Xml <?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:orientation="vertical" > <WebView android:id="@+id/web_view" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout>

    Read the article

  • No resource type specified (at 'id' with value '@+id\st')

    - by Refaat
    I'm new at android programming, I'm now trying to make some buttons, I configured these buttons using the following code: The MainActivity class : public class MainActivity extends Activity { /** Called when the activity is first created. */ Button st,nd,center; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); st = (Button)findViewById(R.id.st); st = (Button)findViewById(R.id.center); st = (Button)findViewById(R.id.nd); } } and the XML Layout: <?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" android:background="@drawable/background" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Hello from animation!!" /> <button android:layout_width="100dp" android:layout_height="50dp" android:text="1st half" android:id="@+id\st" /> // and the other two points defined the same way </LinearLayout> And i got that syntax error: error: Error: No resource type specified (at 'id' with value '@+id\st'). // and the same error with the other two buttons HINT: The R class is imported and accessible from the MainActivity class but it can't read R.id.

    Read the article

  • hint and textview with right gravity and a singleline

    - by codeScriber
    I've opened a bug but i was wondering if anyone encountered this issue and knows a workaround. If you define a text view with a hint inside it, give it right gravity (android:gravity="right") then if you define android:singleLine=true or android:maxLines="1" or android:scrollHorizonatally="true" you don't see the hint. removing the right gravity returns the hint to the left side, removing all the tree params i mentioned above puts the hint on the right side. i want my hint on the right, but i need a single horizontal line... here's the sample layout that doesn't show the hint: <?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="wrap_content" android:padding="5dp"> <EditText android:layout_width="fill_parent" android:layout_gravity="center_vertical|right" android:layout_height="wrap_content" android:layout_margin="6dp" android:textSize="16sp" android:paddingRight="5dp" android:id="@+id/c" android:gravity="right" android:hint="hello!!!" android:scrollHorizontally="true" android:maxLines="1" android:singleLine="true"/> </LinearLayout> i checked on 1.6 and 2.1 emulators and it reproduces 100%, i'm prettysure it's a bug, i don't see the connection between single line and the hint.... what's more the hint got it's own layout in the TextView (mLayout and mHintLayout both exists, in onDraw if the text length is 0 mHintLayout if mHint is not null is used).

    Read the article

  • how to make the user add and delete in android

    - by user3678019
    i have 1 activity .. and in this activity i have 2 web view next to each other , i would like to add , ADD and Delete Button that can add one more web view next to the last web view , and the delete wish will delete any of the web view the user choose . and i want to make the user but it in the order he want like webview 1 first then webview 2 second how can i do this this is mu main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="test.zezo.test.Main$PlaceholderFragment" > <HorizontalScrollView android:id="@+id/horizontalScrollView2" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignParentTop="true" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" > <WebView android:id="@+id/webView1" android:layout_width="350dp" android:layout_height="match_parent" android:layout_alignParentLeft="true" /> <WebView android:id="@+id/webView22" android:layout_width="350dp" android:layout_height="match_parent" android:layout_toRightOf="@+id/webView1" android:layout_alignParentLeft="true" /> </LinearLayout> </HorizontalScrollView> and this is a part of my main.java webView = (WebView) findViewById(R.id.webView1); String url = "http://google.com"; webView.getSettings().setJavaScriptEnabled(true); webView.loadUrl(url); webView.setWebChromeClient(new WebChromeClient()); webView.setWebViewClient(new WebViewClient()); WebView webView22 = (WebView)findViewById(R.id.webView22); webView22.getSettings().setJavaScriptEnabled(true); webView22.loadUrl("google.com); webView22.setWebChromeClient(new WebChromeClient()); webView22.setWebViewClient(new WebViewClient()); so how can i do the ADD and DELETE and re Order Buttons to it and one more thing it should be save so when he reopen the app it will be the same as after he add or delete or re order

    Read the article

  • Android: How to change my ExpandAnimation class to handle animation correctly?

    - by IamStalker
    here is my animation class that i have taken from Udnic - thanks m8, but i'm using it "not from closed position but from opened" and it's jumps and not behaving correctly. what should i do? public class ExpandAnimation extends Animation { private View mAnimatedView; private LinearLayout.LayoutParams mViewLayoutParams; public int mMarginStart, mMarginEnd; private boolean mIsVisibleAfter = false; private boolean mWasEndedAlready = false; private ImageView mImageView; /** * Initialize the animation * @param view The layout we want to animate * @param duration The duration of the animation, in ms */ public ExpandAnimation(View view, int duration, ImageView imageView) { setDuration(duration); mImageView = imageView; mAnimatedView = view; mViewLayoutParams = (LinearLayout.LayoutParams) view.getLayoutParams(); mMarginStart = mMarginEnd = 0; // decide to show or hide the view mIsVisibleAfter = (view.getVisibility() == View.VISIBLE); //mIsVisibleAfter = (mViewLayoutParams.bottomMargin == 0); mMarginStart = mViewLayoutParams.bottomMargin; if(mMarginStart != 0) mMarginStart = 0 - view.getHeight(); mMarginEnd = (mMarginStart == 0 ? (0 - view.getHeight()) : 0); view.setVisibility(View.VISIBLE); mImageView.setImageResource(R.drawable.expand_open); } @Override public void initialize(int width, int height, int parentWidth, int parentHeight) { super.initialize(width, height, parentWidth, parentHeight); } @Override protected void applyTransformation(float interpolatedTime, Transformation t) { super.applyTransformation(interpolatedTime, t); if (interpolatedTime < 1.0f) { // Calculating the new bottom margin, and setting it mViewLayoutParams.bottomMargin = mMarginStart + (int) ((mMarginEnd - mMarginStart) * interpolatedTime); // Invalidating the layout, making us seeing the changes we made mAnimatedView.requestLayout(); // Making sure we didn't run the ending before (it happens!) } else if (!mWasEndedAlready) { mViewLayoutParams.bottomMargin = mMarginEnd; mAnimatedView.requestLayout(); // if (mIsVisibleAfter) { if(mMarginEnd != 0) { mAnimatedView.setVisibility(View.GONE); mImageView.setImageResource(R.drawable.expand_close); } mWasEndedAlready = true; } } }

    Read the article

  • Image overlapping in widget

    - by Hunt
    I am trying to create a widget in android in which when I click over image the image gets changed with a new one -- kind of toggle image. But when I click over it, the image overwrites over the old one rather then replacing the new one. I don't know whether this is the way the widget works or am I doing something wrong. My images are semi-transparent so in case one overrides another one can see the image which is being overlapped. This is the code that I have written in OnReceive by overriding it: @Override public void onReceive(Context context, Intent intent){ if (intent.getAction().equals(iAlertConstant.ACTION_WIDGET_UPDATE_FROM_WIDGET)) { RemoteViews remoteViews = new RemoteViews(context.getPackageName(),R.layout.mywidget); remoteViews.setImageViewResource(R.id.btnOnOff,R.drawable.offbtn); ComponentName thisWidget = new ComponentName(context, EmergencyWidget.class); AppWidgetManager.getInstance(context).updateAppWidget(thisWidget, remoteViews); } else super.onReceive(context, intent); } Layout <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="@drawable/widget_background" android:paddingLeft="10.0dip" android:paddingTop="8.0dip" android:paddingRight="10.0dip" android:paddingBottom="8.0dip" android:layout_width="fill_parent" android:layout_height="72dp" android:layout_marginLeft="10.0dip" android:layout_marginTop="10.0dip" android:layout_marginRight="10.0dip" android:id="@+id/emergencyWidget" android:orientation="horizontal"> <ImageView android:background="@drawable/offbtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="7dp" android:layout_marginLeft="4dp" android:layout_marginRight="4dp" android:layout_gravity="right" android:id="@+id/btnOnOff" /> </LinearLayout>

    Read the article

  • RelativeLayout does not shrink in height

    - by rudas
    Hi, I cannot get my relative layuot view to shrink when using it in the follwing layout, used as a dialog. In below example the scrollview always expands to fill the entire dialog which looks very ugly if there is not much actual content. I have tried most combinations of fill_parent, wrap_content etc without success. The problem seems to be that setting the button to "align_bottom" will cause the dialog to fill its height. But if I change the order and have to button placed below the scrollview the button will not be visible if a lot of content is shown... Please help /Rudas <RelativeLayout android:id="@+id/RelativeLayout01" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="wrap_content"> <ScrollView android:id="@+id/ScrollView01" android:layout_above="@+id/dialogCloseButton" android:layout_alignParentTop="true" android:layout_width="wrap_content" android:layout_height="wrap_content"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/dialogContent" android:orientation="vertical" android:paddingBottom="10dp"> <TextView android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content"> </TextView> </LinearLayout> </ScrollView> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Close" android:id="@+id/dialogCloseButton" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true"></Button> </RelativeLayout>

    Read the article

  • What i am doing wrong with Class Overview?

    - by RFM software
    This code not work. Anyone can helpme? .java package rfmsoftware.util.test1; import android.app.Activity; import android.os.Bundle; public class test1 extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button = (Button)findViewById(R.id.Button01); <---- Error at this line !? } } .xml <?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" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <EditText android:id="@+id/EditText01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="10"></EditText> <Button android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/Scan"></Button> <View android:id="@+id/View01" android:layout_width="wrap_content" android:layout_height="wrap_content"></View> </LinearLayout> .error Button cannot be resolved to a type (type Java problem) ???

    Read the article

  • Why doesn't my text be bold when displaying on device screen

    - by john123
    My string.xml: <!--I try to bold my argument %s, like below:--> <string name="hello">Hello to: <b>%s</b> !</string> My layout main.xml: <LinearLayout ...> <TextView android:id="@+id/hello_txt" ... .../> </LinearLayout> My Fragment class: public class MyFragment extends Fragment{ TextView helloTxt; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); helloTxt = (TextView) findViewById(R.id.hello_txt); } @Override public void onStart() { super.onStart(); //pass "Monday" as the argument to my string helloTxt.setText(String.format(getString(R.string.hello), "Monday")); } } When I run my app on my device, I got "Hello to: Monday !" displaying on screen, but the "Monday" is not bold, but I used <b> in my string.xml. Why it is not bold??

    Read the article

  • Play Video From Raw Folder

    - by SterAllures
    Evening, I've just started programming with android and made a few programs and everything so I'm still kind of a novice but im trying to understand it all. So here's my problem, I'm trying to play a video, the thing is, I got it working when I Stream it from an URL with VideoView over the internet or when i place in on my sdcard. What I want to do now is play a video I've got in my res/raw folder, but it only plays audio and I don't understand why, it doesn't give any error in my logcat as far as I can see, also couldn't really find a solution with google since most of the answers are about VideoView and just put the video on your SDCard. Now someone told me I had to use setDisplay (SurfaceHolder) and I've also tried that but I still only get the audio. I hope somebody can help me to find a solution to this problem. VideoDemo.java package nl.melvin.videodemo; import android.app.Activity; import android.os.Bundle; import android.media.MediaPlayer; import android.view.SurfaceHolder; import android.view.SurfaceView; public class videodemo extends Activity { public SurfaceHolder holder; public SurfaceView surfaceView; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); MediaPlayer mp = MediaPlayer.create(this, R.raw.mac); mp.setDisplay(holder); mp.start(); } } XML <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" > <SurfaceView android:id="@+id/surfaceview" android:layout_width="fill_parent" android:layout_height="fill_parent"> </SurfaceView>> </LinearLayout> I've also tried Uri.parse but it says it can't play the video (.mp4 format).

    Read the article

  • Scala implicit dynamic casting

    - by weakwire
    I whould like to create a scala Views helper for Android Using this combination of trait and class class ScalaView(view: View) { def onClick(action: View => Any) = view.setOnClickListener(new OnClickListener { def onClick(view: View) { action(view) } }) } trait ScalaViewTrait { implicit def view2ScalaView(view: View) = new ScalaView(view) } I'm able to write onClick() like so class MainActivity extends Activity with ScalaViewTrait { //.... val textView = new TextView(this) textView.onClick(v => v.asInstanceOf[TextView] setText ("asdas")) } My concern is that i want to avoid casting v to TextView v will always be TextView if is applied to a TextView LinearLayout if applied to LinearLayout and so on. Is there any way that v gets dynamic casted to whatever view is applied? Just started with Scala and i need your help with this. UPDATE With the help of generics the above get's like this class ScalaView[T](view: View) { def onClick(action: T => Any) = view.setOnClickListener(new OnClickListener { def onClick(view: View) { action(view.asInstanceOf[T]) } }) } trait ScalaViewTrait { implicit def view2ScalaView[T](view: View) = new ScalaView[T](view) } i can write onClick like this view2ScalaView[TextView](textView) .onClick(v => v.setText("asdas")) but is obvious that i don't have any help from explicit and i moved the problem instead or removing it

    Read the article

  • Android: Speeding up display of (html-formatted) text

    - by prepbgg
    My app uses a StringBuilder to assemble paragraphs of text which are then displayed in a TextView within a ScrollView. The displaytext.xml layout file is: <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#FFFFFF" xmlns:android="http://schemas.android.com/apk/res/android"> <ScrollView android:id="@+id/ScrollView01" android:layout_width="fill_parent" android:layout_height="wrap_content" > <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/display_text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#000000" > </TextView> </ScrollView> </LinearLayout> and the code that displays the StringBuilder object sbText is setContentView(R.layout.displaytext); TextView tv = (TextView)findViewById(R.id.display_text); tv.setText(Html.fromHtml(sbText.toString())); This works OK, except that it gets very slow as the amount of text grows. For example, to display 50 paragraphs totalling about 50KB of text takes over 5 seconds just to execute those three lines of code. Can anyone suggest how I can speed this up, please?

    Read the article

  • Custom android preference type loses focus when typing

    - by Brian
    I created a simple preference class that shows an AutoCompleteTextView control and it displays properly but when i focus on the AutoCompleteTextView and start typing it brings up the keyboard but then immediately loses focus on the control. Any idea why this loses focus? Here's what i did to create the view. the inflated layout is just a basic linear layout with a title textview in it. I could change it to a dialog preference instead I guess but it'd be smoother if it could be part of the base view. @Override protected View onCreateView(ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.base_preference, null); if (mHint != null) { TextView hintView = (TextView) layout.findViewById(R.id.PreferenceHintTextView); hintView.setText(mHint); } TextView titleView = (TextView) layout.findViewById(R.id.PreferenceTitleTextView); titleView.setText(getTitle()); AutoCompleteTextView inputView = new AutoCompleteTextView(getContext()); inputView.setGravity(Gravity.FILL_HORIZONTAL); ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getContext(), R.layout.auto_complete_text_list_item, getEntries()); inputView.setAdapter(adapter); inputView.setThreshold(1); inputView.setOnItemSelectedListener(this); layout.addView(inputView); return layout; }

    Read the article

  • Layout resize animation

    - by Marcin Sosna
    I have layout: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/main_fragment_container" android:layout_width="fill_parent" android:layout_height="fill_parent"> <RelativeLayout android:id="@+id/left_fragments_layout" android:layout_width="0dip" android:layout_height="fill_parent" android:layout_weight="1" android:background="#00F"> </RelativeLayout> <RelativeLayout android:id="@+id/graph_fragment_container" android:layout_width="0dip" android:layout_height="fill_parent" android:layout_weight="2.2" android:background="#666"> </RelativeLayout> <RelativeLayout android:id="@+id/right_fragments_layout" android:layout_width="0dip" android:layout_height="fill_parent" android:layout_weight="1" android:background="#00F"> </RelativeLayout> When I set visibility to GONE on left and right fragment container then they are animated to left and right. I try to set scale animation on resize center graph_fragment_container, my code: <scale android:fromXScale="100%" android:toXScale="50%" android:fillAfter="true" android:fillEnabled="true" android:duration="7000" /> Java code: Animation toLeftOut = AnimationUtils.loadAnimation( MainActivity.this, R.anim.to_left_out ); Animation toRightOut = AnimationUtils.loadAnimation( MainActivity.this, R.anim.to_right_out ); Animation scale = AnimationUtils.loadAnimation( MainActivity.this, R.anim.scal ); graphContainer.startAnimation( scale ); leftFragmentsLayout.startAnimation( toLeftOut ); rightFragmentsLayout.startAnimation( toRightOut ); Now graphContainer was resize after right and left layout animation end, and user see a grey backgound before center layout was resize.

    Read the article

  • Spinner activity not working

    - by user1696863
    I'm trying to create an activity, RateCardActivity, which has a spinner in it. My layout file for RateCardActivity is rate_card. My RateCardActivity looks like the following. public class RateCardActivity { public void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.rate_card); Spinner spinner = (Spinner) findViewById(R.id.select_city); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.select_city, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); } } The layout file rate_card is: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:custom="http://schemas.android.com/apk/res/com.olacabs.customer" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:id="@+id/textView1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@android:color/darker_gray" android:gravity="center" android:paddingBottom="4dp" android:paddingTop="4dp" android:text="@string/rate_card" android:textColor="@color/white" android:textSize="20dp" custom:customFont="litera_bold.ttf" /> <Spinner android:id="@+id/select_city" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout> The RateCardActivity is called from another activity using an intent (I'm sure there is nothing wrong with that part of the code as when I substitute RateCardActivity with another activity, the application works fine). When I try to open the RateCardActivity in the application in emulator, the application crashes and I got the message "The application has stopped unexpectedly. Please try again later." I can't seem to understand what I'm doing wrong, and want to know how to correct this?

    Read the article

  • Spinner original text

    - by user1696863
    I'm trying my Spinner to display "Select City" before the Spinner has itself been clicked by the user. How can I do this? My current XML code is: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:custom="http://schemas.android.com/apk/res/com.olacabs.customer" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/page_background" android:orientation="vertical" > <TextView android:id="@+id/textView1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@android:color/darker_gray" android:gravity="center" android:paddingBottom="4dp" android:paddingTop="4dp" android:text="@string/rate_card" android:textColor="@color/white" android:textSize="20dp" custom:customFont="litera_bold.ttf" /> <Spinner android:id="@+id/select_city" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="40dp" android:prompt="@string/selectCity" /> </LinearLayout> Also, what does android:spinnerMode exactly do. I tried changing its value to dropdown but nothing happened and the application still showed a popup dialogue. My activity that implements this XML file is: public class RateCardActivity extends OlaActivity { public void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.rate_card); Spinner spinner = (Spinner) findViewById(R.id.select_city); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.select_city, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); } }

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18  | Next Page >