android-widget

Android.widget,textView cannot be cast to android.widget,button

风格不统一 提交于 2019-12-17 17:44:17
问题 I keep getting a runtime error when launching my activity and it says android.widget.textview cannot be cast to android.widget.button? XML: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/RelativeLayout1" android:layout_width="fill_parent" android:layout_height="match_parent" android:orientation="vertical" tools:ignore="HardcodedText" > <TextView android:id="@+id

Android Spinner - How to make dropdown view transparent?

ε祈祈猫儿з 提交于 2019-12-17 11:02:01
问题 I have a custom spinner dropdown xml file in /res/layout/: spinner_view_dropdown.xml: <?xml version="1.0" encoding="UTF-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/spinner_item_dropdown" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@android:color/transparent" style="@style/spinner_item_dropdown" /> I'm setting the spinner dropdown via java: // "Spinner", aka breadcrumbs Spinner spin = (Spinner)

Android Spinner - How to make dropdown view transparent?

别等时光非礼了梦想. 提交于 2019-12-17 11:01:56
问题 I have a custom spinner dropdown xml file in /res/layout/: spinner_view_dropdown.xml: <?xml version="1.0" encoding="UTF-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/spinner_item_dropdown" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@android:color/transparent" style="@style/spinner_item_dropdown" /> I'm setting the spinner dropdown via java: // "Spinner", aka breadcrumbs Spinner spin = (Spinner)

android webview stay in app

邮差的信 提交于 2019-12-17 10:57:42
问题 I have a webview in my android app, but when someone navigates around the site, it opens in a new window, i want it to stay inside the webview.. is there a way to do this easily? Here is the code in my activity: super.onCreate(savedInstanceState); setContentView(R.layout.shop); WebView webview; webview = (WebView) findViewById(R.id.webview); webview.getSettings().setJavaScriptEnabled(true); webview.loadUrl("http://www.google.co.uk"); 回答1: You'll have to create a WebViewClient : public class

How to customize the width and height when show an Activity as a Dialog

时光怂恿深爱的人放手 提交于 2019-12-17 10:53:28
问题 If I have defined a Activity: public class DialogActivity extends Activity{ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(dialog_activity.xml); } } I would like to display the above activity like a dialog, so in the AndroidManifest.xml file, I declare this activity like below: <activity android:name=".DialogActivity" android:theme="@android:style/Theme.Dialog"/> Everything is fine at this point, my DialogActivity showed as a

How to display a two column ListView in Android?

梦想的初衷 提交于 2019-12-17 10:29:36
问题 I have an android application that shows a grid view that shows: 1 2 3 4 GridView gridview=(GridView)findViewById(R.id.GridView_test); DataBaseHelper dbhelper=new DataBaseHelper(this); ArrayList<String> test=new ArrayList<String>(5); backlinksadapter.add("1"); backlinksadapter.add("2"); backlinksadapter.add("3"); backlinksadapter.add("4"); ArrayAdapter mAdapter=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, test); gridview.setAdapter(mAdapter); By the moment is working,

Create custom lockscreen for android 4.0 or above?

拜拜、爱过 提交于 2019-12-17 10:15:00
问题 I want to create custom lockScreen for android 4.0 and above, I have tried widget to create lockscreen but it supports only android 4.2. Is there any other way to create custom android lockScreen? 回答1: I have found snippets somewhere on internet few months ago, I have made changes and recently uploaded the working demo on my github account, You can have a look at this Note: It will disable "hardware" home button. I hope it will be helpfull !! Screenshots: It provides lockscreen in API 8 or

How to disable items in a List View?

谁说胖子不能爱 提交于 2019-12-17 09:40:27
问题 I have a list view which is populated via records from the database. Now i have to make some records visible but unavailable for selection, how can i achieve that? here's my code public class SomeClass extends ListActivity { private static List<String> products; private DataHelper dh; public void onCreate(Bundle savedInstanceState) { dh = new DataHelper(this); products = dh.GetMyProducts(); /* Returns a List<String>*/ super.onCreate(savedInstanceState); setListAdapter(new ArrayAdapter<String>

Widgets don't respond when re-added through code

瘦欲@ 提交于 2019-12-17 07:34:26
问题 I am working on a launcher. It let's users add widgets from the list, it works fine. I store information about the widget (PackageName, ClassName and it's co-ordinates on the screen) in my database when the user adds one to the screen. When the application is restarted (or the device itself) I add those (user selected) widgets back through code: // APPWIDGET_HOST_ID is any number you like appWidgetManager = AppWidgetManager.getInstance(this); appWidgetHost = new AppWidgetHost(this, APPWIDGET

How to add views dynamically to a RelativeLayout already declared in the xml layout?

筅森魡賤 提交于 2019-12-17 07:31:10
问题 I declared a RelativeLayout in a xml layout file. Now I want to add Views from code to the existing Layout. I added a Button dynamically to this existing layout as below through code: rLayout = (RelativeLayout)findViewById(R.id.rlayout); LayoutParams lprams = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); Button tv1 = new Button(this); tv1.setText("Hello"); tv1.setLayoutParams(lprams); tv1.setId(1); rLayout.addView(tv1); Now I need to add another Button to the right of