how to validate a URL / website name in EditText in Android?

Short answer Use WEB_URL pattern in Patterns Class Patterns.WEB_URL.matcher(potentialUrl).matches() It will return True if URL is valid and false if URL is invalid. Long answer As of Android API level 8 there is a WEB_URL pattern. Quoting the source, it “match[es] most part of RFC 3987”. If you target a lower API level you could … Read more

Android Spinner – How to make dropdown view transparent?

You can override the style for the dropdown, and the dropdown item by using a Theme in your app that inherits from one of the Android themes, then override the android:dropDownSpinnerStyle, or android:spinnerDropDownItemStyle, and even the android:dropDownListViewStyle attribute of the theme, pointing to your own custom style instead of the Android style that is defined … Read more

Horizontal “tab”ish scroll between views

(update 20110905: Official android tools now do this better) I cloned Eric Taix’s http://code.google.com/p/andro-views/ on github https://github.com/olibye/AndroViews Then applied the patches from above: JonO’s patch Tom de Waard’s patch Split into a library and an example, allowing simple inclusion in other projects I would have made this comment above, however I didn’t appear able to … Read more

Disable ScrollView action

This might be a bit late but I ran into the same problem so my solution is similar to above, had to disable the OnTouchListener as follows: // Get the ScrollView final ScrollView myScroll = (ScrollView) findViewById(R.id.display_scrollview); // Disable Scrolling by setting up an OnTouchListener to do nothing myScroll.setOnTouchListener( new OnTouchListener(){ @Override public boolean onTouch(View … Read more

android widget on click event

@Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { for (int i = 0; i < appWidgetIds.length; i++) { int appWidgetId = appWidgetIds[i]; Intent intent = new Intent(context, TaskManagerActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget); views.setOnClickPendingIntent(R.id.widget_layout, pendingIntent); appWidgetManager.updateAppWidget(appWidgetId, views); } } In widget.xml I have root element … Read more

How to create android app with app widget in single application

Create and configure widget To register a widget you create a BroadcastReceiver with an intent filter for the android.appwidget.action.APPWIDGET_UPDATE action. <receiver android:icon=”@drawable/icon” android:label=”Example Widget” android:name=”MyWidgetProvider” > <intent-filter > <action android:name=”android.appwidget.action.APPWIDGET_UPDATE” /> </intent-filter> <meta-data android:name=”android.appwidget.provider” android:resource=”@xml/widget_info” /> </receiver> You also specify the meta-data for the widget via the android:name=”android.appwidget.provider attribute. The configuration file referred by this … Read more