Search Results

Search found 911 results on 37 pages for 'textview'.

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

  • adding a UIScrollView as a superview of 2 UITextview

    - by Risma
    hi i have 2 textview in a viewcontroller. the 1st textview is not editable, but the 2nd is editable. i want to make both of them scroll in the same position and size when the keyboard is appear. I think i have to use UIScrollView as base of both of textview. And then i add the UIScrollView in xib (bot of textview are made in xib too). and this is the picture if this hierarchy : in the viewDidLoad method, i add this code : - (void)viewDidLoad { [super viewDidLoad]; [scrollTextView addSubview:lineNumberTextView]; [scrollTextView addSubview:_codeTextView]; [lineNumberTextView bringSubviewToFront:scrollTextView]; [_codeTextView bringSubviewToFront:scrollTextView]; } but when i tap on the 2nd textview, the keyboard is not appear. What i have to do? thx for the advices

    Read the article

  • How to obtain listview information without refreshing the page?

    - by user1808098
    I am currently developing an Android Application for my Final Year Project. But to be honest I do not have any basic knowledges and everything started from scratch and referring to online tutorials a lot. Here is my question, I was trying to retrieve data from listview activity. There are two listview in my page using button. I was able to display the first listview but when it get data for the second listview, the data for first listview is disappeared because the page is refreshed, vice versa. What code should I modified to get both the data in the page? (Database not implemented yet) Please help, thanks a lot. Below are my codings. Codings for XML. <!-- Location --> <TextView android:id="@+id/TextViewLocation" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:layout_marginBottom="10dip" android:text="Location Information" android:gravity="center" android:textSize="15dip" android:textColor="#025f7c"/> <!-- Condition Label --> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#372c24" android:text="Traffic Condition"/> <Button android:id="@+id/inputListView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:layout_marginBottom="10dip" android:text="choose one..."/> <!-- Comment Label --> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#372c24" android:text="What's Happening?"/> <Button android:id="@+id/inputListView2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:layout_marginBottom="10dip" android:text="choose one..."/> <!-- Suggestion Label --> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#372c24" android:text="Comments / Suggestion"/> <EditText android:layout_width="fill_parent" android:layout_height="80dp" android:layout_marginTop="5dip" android:layout_marginBottom="10dip" android:singleLine="true"/> <!-- Image button --> <Button android:id="@+id/btnImage" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:text="Upload Image"/> <!-- Report button --> <Button android:id="@+id/btnReportCheckin" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:text="Report"/> <!-- Link to Logout --> <TextView android:id="@+id/linkLogout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:layout_marginBottom="40dip" android:text="Log Out" android:gravity="center" android:textSize="20dip" android:textColor="#025f7c"/> </LinearLayout> <!-- Check or Report Form Ends --> Codings for Activity Class public class CheckinActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set View to checkin.xml setContentView(R.layout.checkin); /* TextView LocationView = (TextView) findViewById(R.id.TextViewLocation); Intent h = getIntent(); // getting attached intent data String address = h.getStringExtra("address"); // displaying selected product name LocationView.setText(address); */ Button ListViewScreen = (Button) findViewById(R.id.inputListView); //Listening to Button ListViewScreen.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //Switching to ListView Screen Intent i = new Intent(getApplicationContext(), ListViewActivity.class); startActivity(i); } } ); Button SelectedView = (Button) findViewById(R.id.inputListView); Intent i = getIntent(); // getting attached intent data String product = i.getStringExtra("product"); // displaying selected product name SelectedView.setText(product); Button ListView2Screen = (Button) findViewById(R.id.inputListView2); //Listening to Button ListView2Screen.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //Switching to ListView Screen Intent j = new Intent(getApplicationContext(), ListView2Activity.class); startActivity(j); } } ); Button SelectedView2 = (Button) findViewById(R.id.inputListView2); Intent j = getIntent(); // getting attached intent data String product2 = j.getStringExtra("product2"); // displaying selected product name SelectedView2.setText(product2); TextView Logout = (TextView) findViewById(R.id.linkLogout); // Listening to Log out Logout.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { // Closing menu screen // Switching to Login Screen/closing register screen finish(); } }); } } Coding for listview class public class ListViewActivity extends ListActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // storing string resources into Array String[] traffic_condition = getResources().getStringArray(R.array.traffic_condition); // Binding resources Array to ListAdapter this.setListAdapter(new ArrayAdapter<String>(this, R.layout.listitem, R.id.listViewLayout, traffic_condition)); ListView lv = getListView(); // listening to single list item on click lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // selected item String product = ((TextView) view).getText().toString(); // Launching new Activity on selecting single List Item Intent i = new Intent(getApplicationContext(), CheckinActivity.class); // sending data to new activity i.putExtra("product", product); startActivity(i); } }); } } Hope I made myself clear, I can provide a screen shot of my apps if it is required, thanks!

    Read the article

  • Android programming. Application stopped unexpectedly.

    - by user277704
    I've just created a prototype of interface for my android app and tried to run it. Unfortunately I get an error that my app has stopped unexpectedly (my reputation doesn't allow me to post images so follow my links): screenshot of error message This is layout mode of editing. Everything looks as I want so there shouldn't be errors: mobileka.freehostia.com/3.png (I can post only one hyperlink...) This is my main.xml code: <code> <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="top" android:background="@drawable/back" > <TextView android:id="@+id/score" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text = "@string/scoreT" android:textColor="@string/scoreColor" android:gravity = "left" android:typeface="serif" android:textStyle="bold|italic" android:textSize="16sp" android:paddingLeft = "10px" android:paddingTop="4px"/ <TextView android:id = "@+id/scoreTxt" android:layout_toRightOf="@+id/score" android:textSize="16sp" android:paddingTop = "5px" android:paddingLeft="4px" android:typeface="serif" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" 0" android:textColor="@string/scoreTextColor" android:gravity = "left"/> <TextView android:id = "@+id/scoreSeparator" android:layout_toRightOf="@+id/scoreTxt" android:textSize="16sp" android:paddingTop = "3px" android:paddingLeft="4px" android:typeface="serif" android:textStyle="bold" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="|" android:textColor="@string/scoreColor" android:gravity = "left"/> <TextView android:id = "@+id/timerTxt" android:layout_alignParentRight="true" android:textSize="16sp" android:paddingRight="10px" android:paddingTop="4px" android:typeface="serif" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@string/scoreTextColor" android:gravity = "right" android:text="00:00" /> <TextView android:id = "@+id/timer" android:layout_toLeftOf="@+id/timerTxt" android:textColor="@string/scoreColor" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="16sp" android:padding = "3px" android:typeface="serif" android:textStyle="bold|italic" android:text="@string/timerT" android:gravity = "left"/> <TextView android:id = "@+id/timerSeparator" android:layout_toLeftOf="@+id/timer" android:textSize="16sp" android:paddingTop = "3px" android:paddingLeft="4px" android:typeface="serif" android:textStyle="bold" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="|" android:textColor="@string/scoreColor" android:gravity = "left"/> <ImageButton android:id="@+id/buttonOne" android:layout_below="@+id/score" android:layout_marginTop="40px" android:layout_marginLeft="14px" android:layout_width="wrap_content" android:layout_height="wrap_content" android:clickable="true" android:src="@drawable/inactive"/> <ImageButton android:id="@+id/buttonTwo" android:layout_toRightOf="@+id/buttonOne" android:layout_marginTop="63px" android:layout_marginLeft="10px" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/inactive" /> <ImageButton android:id="@+id/buttonThree" android:layout_toRightOf="@+id/buttonTwo" android:layout_marginTop="63px" android:layout_marginLeft="10px" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/inactive" /> <ImageButton android:id="@+id/buttonFour" android:layout_toRightOf="@+id/buttonThree" android:layout_marginTop="63px" android:layout_marginLeft="10px" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/inactive" /> <ImageButton android:id="@+id/buttonFive" android:layout_below="@+id/buttonOne" android:layout_marginTop="40px" android:layout_marginLeft="14px" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/inactive" /> <ImageButton android:id="@+id/buttonSix" android:layout_toRightOf="@+id/buttonFive" android:layout_marginTop="164px" android:layout_marginLeft="10px" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/inactive" /> <ImageButton android:id="@+id/buttonSeven" android:layout_toRightOf="@+id/buttonSix" android:layout_marginTop="164px" android:layout_marginLeft="10px" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/inactive" /> <ImageButton android:id="@+id/buttonEight" android:layout_toRightOf="@+id/buttonSeven" android:layout_marginTop="164px" android:layout_marginLeft="10px" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/inactive" /> <ImageButton android:id="@+id/buttonNine" android:layout_below="@+id/buttonEight" android:layout_marginTop="40px" android:layout_marginLeft="14px" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/inactive" /> <ImageButton android:id="@+id/buttonTen" android:layout_toRightOf="@+id/buttonNine" android:layout_marginTop="264px" android:layout_marginLeft="10px" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/inactive" /> <ImageButton android:id="@+id/buttonEleven" android:layout_toRightOf="@+id/buttonTen" android:layout_marginTop="264px" android:layout_marginLeft="10px" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/inactive" /> <ImageButton android:id="@+id/buttonTwelve" android:layout_toRightOf="@+id/buttonEleven" android:layout_marginTop="264px" android:layout_marginLeft="10px" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/inactive" /> And this is my logcat errors (p.s. line #12 is the first TextView in main.xml): 03-26 22:59:31.670: WARN/dalvikvm(185): threadid=3: thread exiting with uncaught exception (group=0x4001b188) 03-26 22:59:31.727: ERROR/AndroidRuntime(185): Uncaught handler: thread main exiting due to uncaught exception 03-26 22:59:31.784: ERROR/AndroidRuntime(185): java.lang.RuntimeException: Unable to start activity ComponentInfo{kz.androidmarket.www.randomtest1/kz.androidmarket.www.randomtest1.randomTest1}: android.view.InflateException: Binary XML file line #12: Error inflating class 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at android.app.ActivityThread.access$2200(ActivityThread.java:119) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at android.os.Handler.dispatchMessage(Handler.java:99) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at android.os.Looper.loop(Looper.java:123) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at android.app.ActivityThread.main(ActivityThread.java:4363) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at java.lang.reflect.Method.invokeNative(Native Method) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at java.lang.reflect.Method.invoke(Method.java:521) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at dalvik.system.NativeStart.main(Native Method) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at android.view.LayoutInflater.createView(LayoutInflater.java:513) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at android.view.LayoutInflater.inflate(LayoutInflater.java:407) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at android.app.Activity.setContentView(Activity.java:1622) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at kz.androidmarket.www.randomtest1.randomTest1.onCreate(randomTest1.java:11) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): ... 11 more 03-26 22:59:31.784: ERROR/AndroidRuntime(185): Caused by: java.lang.reflect.InvocationTargetException 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at android.widget.TextView.(TextView.java:320) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at java.lang.reflect.Constructor.constructNative(Native Method) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at java.lang.reflect.Constructor.newInstance(Constructor.java:446) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at android.view.LayoutInflater.createView(LayoutInflater.java:500) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): ... 22 more 03-26 22:59:31.784: ERROR/AndroidRuntime(185): Caused by: android.content.res.Resources$NotFoundException: File #ffff9900 from drawable resource ID #0x7f040002: .xml extension required 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at android.content.res.Resources.loadColorStateList(Resources.java:1820) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at android.content.res.TypedArray.getColorStateList(TypedArray.java:289) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): at android.widget.TextView.(TextView.java:627) 03-26 22:59:31.784: ERROR/AndroidRuntime(185): ... 26 more Could anybody help me?

    Read the article

  • I can't understand this issue java.lang.IndexOutOfBoundsException.

    - by praveenb
    I've strange issue, that My application is working fine on some devices, But its crashing one of the client device(on Galaxy Nexus 4.1.1 v) at app starting screen. I get this stack trace from ACRA report. java.lang.IndexOutOfBoundsException at android.graphics.Paint.getTextRunAdvances(Paint.java:1731) at android.graphics.Paint.getTextRunAdvances(Paint.java:1704) at android.text.MeasuredText.addStyleRun(MeasuredText.java:164) at android.text.MeasuredText.addStyleRun(MeasuredText.java:204) at android.text.StaticLayout.generate(StaticLayout.java:281) at android.text.DynamicLayout.reflow(DynamicLayout.java:284) at android.text.DynamicLayout.(DynamicLayout.java:170) at android.widget.TextView.makeSingleLayout(TextView.java:5843) at android.widget.TextView.makeNewLayout(TextView.java:5741) at android.widget.TextView.onMeasure(TextView.java:6098) at android.view.View.measure(View.java:15172) at android.widget.LinearLayout.measureVertical(LinearLayout.java:833) at android.widget.LinearLayout.onMeasure(LinearLayout.java:574) at android.view.View.measure(View.java:15172) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:617) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:399) at android.view.View.measure(View.java:15172) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.view.View.measure(View.java:15172) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1390) at android.widget.LinearLayout.measureVertical(LinearLayout.java:681) at android.widget.LinearLayout.onMeasure(LinearLayout.java:574) at android.view.View.measure(View.java:15172) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2148) at android.view.View.measure(View.java:15172) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1848) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1100) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1273) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725) at android.view.Choreographer.doCallbacks(Choreographer.java:555) at android.view.Choreographer.doFrame(Choreographer.java:525) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711) at android.os.Handler.handleCallback(Handler.java:615) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4745) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) at dalvik.system.NativeStart.main(Native Method) Im seeing above stack trace. I'm unable to understand the issue. Please help me on tacking the issue. Thank you.

    Read the article

  • Layout problem: how to place something on top and bottom?

    - by chow
    I want create a layout, with a horizontal LinearLayout(s) on top and bottom, a ListView fill in middle. How can I define the main.xml. I tried to create a layout with horizontal LinearLayout on top, TextView on bottom, a ListView fill in middle; is ok. But after I modified the bottom TextView to LinearLayout, the bottom LinearLayout disappear. <?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" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:textSize="12px" android:text="something here" android:layout_width="50px" android:layout_height="wrap_content" /> <TextView android:textSize="12px" android:text="something here" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="bottom" > <ListView android:id="@+id/listbody" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <LinearLayout android:orientation="horizontal" android:layout_height="wrap_content" android:layout_width="fill_parent" > <TextView android:layout_height="wrap_content" android:layout_width="0dip" android:layout_weight="1" android:textSize="12px" android:text="50%" /> <TextView android:layout_height="wrap_content" android:layout_width="0dip" android:layout_weight="1" android:textSize="12px" android:text="50%" /> </LinearLayout> </LinearLayout> </LinearLayout> Anybody can tell advise? Please help.

    Read the article

  • AutoCompleteTextView displays 'android.database.sqlite.SQLiteCursor@'... after making selection

    - by user244190
    I am using the following code to set the adapter (SimpleCursorAdapter) for an AutoCompleteTextView mComment = (AutoCompleteTextView) findViewById(R.id.comment); Cursor cComments = myAdapter.getDistinctComments(); scaComments = new SimpleCursorAdapter(this,R.layout.auto_complete_item,cComments,new String[] {DBAdapter.KEY_LOG_COMMENT},new int[]{R.id.text1}); mComment.setAdapter(scaComments); auto_complete_item.xml <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text1" android:layout_width="wrap_content" android:layout_height="wrap_content"/> and thi is the xml for the actual control <AutoCompleteTextView android:id="@+id/comment" android:hint="@string/COMMENT" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="18dp"/> The dropdown appears to work correctly, and shows a list of items. When I make a selection from the list I get a sqlite object ('android.database.sqlite.SQLiteCursor@'... ) in the textview. Anyone know what would cause this, or how to resolve this? thanks Ok I am able to hook into the OnItemClick event, but the TextView.setText() portion of the AutoCompleteTextView widget is updated after this point. The OnItemSelected() event never gets fired, and the onNothingSelected() event gets fired when the dropdown items are first displayed. mComment.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub SimpleCursorAdapter sca = (SimpleCursorAdapter) arg0.getAdapter(); String str = getSpinnerSelectedValue(sca,arg2,"comment"); TextView txt = (TextView) arg1; txt.setText(str); Toast.makeText(ctx, "onItemClick", Toast.LENGTH_SHORT).show(); } }); mComment.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Toast.makeText(ctx, "onItemSelected", Toast.LENGTH_SHORT).show(); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub Toast.makeText(ctx, "onNothingSelected", Toast.LENGTH_SHORT).show(); } }); Anyone alse have any ideas on how to override the updating of the TextView? thanks patrick

    Read the article

  • How to call a new thread from button click

    - by Lynnooi
    Hi, I'm trying to call a thread on a button click (btn_more) but i cant get it right. The thread is to get some data and update the images. The problem i have is if i only update 4 or 5 images then it works fine. But if i load more than 5 images i will get a force close. At times when the internet is slow I will face the same problem too. Can please help me to solve this problem or provide me some guidance? Here is the error i got from LogCat: 04-19 18:51:44.907: ERROR/AndroidRuntime(1034): Uncaught handler: thread main exiting due to uncaught exception 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): java.lang.NullPointerException 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at mobile9.android.gallery.GalleryWallpapers.setWallpaperThumb(GalleryWallpapers.java:383) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at mobile9.android.gallery.GalleryWallpapers.access$4(GalleryWallpapers.java:320) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at mobile9.android.gallery.GalleryWallpapers$1.handleMessage(GalleryWallpapers.java:266) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at android.os.Handler.dispatchMessage(Handler.java:99) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at android.os.Looper.loop(Looper.java:123) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at android.app.ActivityThread.main(ActivityThread.java:4310) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at java.lang.reflect.Method.invokeNative(Native Method) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at java.lang.reflect.Method.invoke(Method.java:521) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at dalvik.system.NativeStart.main(Native Method) My Code: public class GalleryWallpapers extends Activity implements Runnable { public static String MODEL = android.os.Build.MODEL ; private static final String rootURL = "http://www.uploadhub.com/mobile9/gallery/c/"; private int wallpapers_count = 0; private int ringtones_count = 0; private int index = 0; private int folder_id; private int page; private int page_counter = 1; private String family; private String keyword; private String xmlURL = ""; private String thread_op = "xml"; private ImageButton btn_back; private ImageButton btn_home; private ImageButton btn_filter; private ImageButton btn_search; private TextView btn_more; private ProgressDialog pd; GalleryExampleHandler myExampleHandler = new GalleryExampleHandler(); Context context = GalleryWallpapers.this.getBaseContext(); Drawable image; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MODEL = "HTC Legend"; // **needs to be remove after testing** try { MODEL = URLEncoder.encode(MODEL,"UTF-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.gallerywallpapers); Bundle b = this.getIntent().getExtras(); family = b.getString("fm").trim(); folder_id = Integer.parseInt(b.getString("fi")); keyword = b.getString("kw").trim(); page = Integer.parseInt(b.getString("page").trim()); WindowManager w = getWindowManager(); Display d = w.getDefaultDisplay(); final int width = d.getWidth(); final int height = d.getHeight(); xmlURL = rootURL + "wallpapers/1/?output=rss&afm=wallpapers&mdl=" + MODEL + "&awd=" + width + "&aht=" + height; if (folder_id > 0) { xmlURL = xmlURL + "&fi=" + folder_id; } pd = ProgressDialog.show(GalleryWallpapers.this, "", "Loading...", true, false); Thread thread = new Thread(GalleryWallpapers.this); thread.start(); btn_more = (TextView) findViewById(R.id.btn_more); btn_more.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { myExampleHandler.filenames.clear(); myExampleHandler.authors.clear(); myExampleHandler.duration.clear(); myExampleHandler.fileid.clear(); btn_more.setBackgroundResource(R.drawable.btn_more_click); page = page + 1; thread_op = "xml"; xmlURL = rootURL + "wallpapers/1/?output=rss&afm=wallpapers&mdl=" + MODEL + "&awd=" + width + "&aht=" + height; xmlURL = xmlURL + "&pg2=" + page; index = 0; pd = ProgressDialog.show(GalleryWallpapers.this, "", "Loading...", true, false); Thread thread = new Thread(GalleryWallpapers.this); thread.start(); } }); } public void run() { if(thread_op.equalsIgnoreCase("xml")){ readXML(); } else if(thread_op.equalsIgnoreCase("getImg")){ getWallpaperThumb(); } handler.sendEmptyMessage(0); } private Handler handler = new Handler() { @Override public void handleMessage(Message msg) { int count = 0; if (!myExampleHandler.filenames.isEmpty()){ count = myExampleHandler.filenames.size(); } count = 6; if(thread_op.equalsIgnoreCase("xml")){ pd.dismiss(); thread_op = "getImg"; btn_more.setBackgroundResource(R.drawable.btn_more); } else if(thread_op.equalsIgnoreCase("getImg")){ setWallpaperThumb(); index++; if (index < count){ Thread thread = new Thread(GalleryWallpapers.this); thread.start(); } } } }; private void readXML(){ if (xmlURL.length() != 0) { try { /* Create a URL we want to load some xml-data from. */ URL url = new URL(xmlURL); /* Get a SAXParser from the SAXPArserFactory. */ SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); /* Get the XMLReader of the SAXParser we created. */ XMLReader xr = sp.getXMLReader(); /* * Create a new ContentHandler and apply it to the * XML-Reader */ xr.setContentHandler(myExampleHandler); /* Parse the xml-data from our URL. */ xr.parse(new InputSource(url.openStream())); /* Parsing has finished. */ /* * Our ExampleHandler now provides the parsed data to * us. */ ParsedExampleDataSet parsedExampleDataSet = myExampleHandler .getParsedData(); } catch (Exception e) { //showDialog(DIALOG_SEND_LOG); } } } private void getWallpaperThumb(){ int i = this.index; if (!myExampleHandler.filenames.elementAt(i).toString().equalsIgnoreCase("")){ image = ImageOperations(context, myExampleHandler.thumbs.elementAt(i).toString(), "image.jpg"); } } private void setWallpaperThumb(){ int i = this.index; if (myExampleHandler.filenames.elementAt(i).toString() != null) { String file_info = myExampleHandler.filenames.elementAt(i).toString(); String author = "\nby " + myExampleHandler.authors.elementAt(i).toString(); final String folder = myExampleHandler.folder_id.elementAt(folder_id).toString(); final String fid = myExampleHandler.fileid.elementAt(i).toString(); ImageView imgView = new ImageView(context); TextView tv_filename = null; TextView tv_author = null; switch (i + 1) { case 1: imgView = (ImageView) findViewById(R.id.image1); tv_filename = (TextView) findViewById(R.id.filename1); tv_author = (TextView) findViewById(R.id.author1); break; case 2: imgView = (ImageView) findViewById(R.id.image2); tv_filename = (TextView) findViewById(R.id.filename2); tv_author = (TextView) findViewById(R.id.author2); break; case 3: imgView = (ImageView) findViewById(R.id.image3); tv_filename = (TextView) findViewById(R.id.filename3); tv_author = (TextView) findViewById(R.id.author3); break; case 4: . . . . . case 10: imgView = (ImageView) findViewById(R.id.image10); tv_filename = (TextView) findViewById(R.id.filename10); tv_author = (TextView) findViewById(R.id.author10); break; } if (image.getIntrinsicHeight() > 0) { imgView.setImageDrawable(image); } else { imgView.setImageResource(R.drawable.default_wallpaper); } tv_filename.setText(file_info); tv_author.setText(author); imgView.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { // Perform action on click } }); } } private Drawable ImageOperations(Context ctx, String url, String saveFilename) { try { InputStream is = (InputStream) this.fetch(url); Drawable d = Drawable.createFromStream(is, "src"); return d; } catch (MalformedURLException e) { e.printStackTrace(); return null; } catch (IOException e) { e.printStackTrace(); return null; } } }

    Read the article

  • ImageViews in a ListView not aligned vertically [Mono for Android]

    - by shalmon
    I'm very new to developing apps to android, so bear with me. Having said that, I'm trying to make a list with a image to the left and a title and description to the right of the image. The image is downloaded from the web in the background and then set in the UI as they complete. This all works. However, the images are not aligned properly and I simply cannot understand why. I'm thinking it has something to do with the layout defined in the xml file? I tried using android:layout_alignParentLeft="true" and android:layout_gravity="left" but that got me nowhere. Then I didn't know how to proceed, even after googling every way I could think of. I'm sorry if this is very basic, but I would really appreciate some help here. Here's a pic of the situation: And here's my layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/widget28" android:layout_width="fill_parent" android:layout_height="80px" > <ImageView android:id="@+id/imageItem" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_alignParentLeft="true" > </ImageView> <LinearLayout android:id="@+id/linearText" android:layout_width="wrap_content" android:layout_height="fill_parent" android:orientation="vertical" android:layout_marginLeft="10px" android:layout_marginTop="10px" > <TextView android:id="@+id/textTop" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" > </TextView> <TextView android:id="@+id/textBottom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" > </TextView> </LinearLayout> </LinearLayout> I appreciate any help you can offer.

    Read the article

  • Dynmically added row in TableLayout

    - by Balaji
    This is my activity class i want to add one textview to TableRow but i cannot show the textview in TableLayout. Activity import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.view.LayoutInflater; import android.view.ViewGroup.LayoutParams; import android.widget.TableLayout; import android.widget.TableRow; import android.widget.TextView; import android.widget.LinearLayout; public class TableRunTime extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TableLayout tl = (TableLayout) findViewById(R.id.arcitle_content_table); TextView txt = new TextView(this); TableRow tr = new TableRow(this); txt.setText("Book Name"); txt.setTextColor(Color.WHITE); txt.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); tr.addView(txt); tl.addView(tr, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); } } This is manifest file any one help how to show textview in TableLayout

    Read the article

  • Displaying music list using custom lists instead of array adapters

    - by Rahul Varma
    Hi, I have displayed the music list in a list view. The list is obtained from a website. I have done this using Arraylist. Now, i want to iterate the same program using custom lists and custom adapters instead of array list. The code i have written using array lists is... public class MusicListActivity extends Activity { MediaPlayer mp; File mediaFile; TextView tv; TextView albumtext; TextView artisttext; ArrayList<String> al=new ArrayList<String>(); //ArrayList<String> al=new ArrayList<String>(); ArrayList<String> node=new ArrayList<String>(); ArrayList<String> filepath=new ArrayList<String>(); ArrayList<String> imgal=new ArrayList<String>(); ArrayList<String> album=new ArrayList<String>(); ArrayList<String> artist=new ArrayList<String>(); ListView lv; Object[] webImgListObject; String[] stringArray; XMLRPCClient client; String loginsess; HashMap<?, ?> siteConn = null; //ImageView im; Bitmap img; String s; int d; int j; StreamingMediaPlayer sm; int start=0; Intent i; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.openadiuofile); lv=(ListView)findViewById(R.id.list1); al=getIntent().getStringArrayListExtra("titles"); //node=getIntent().getStringArrayListExtra("nodeid"); filepath=getIntent().getStringArrayListExtra("apath"); imgal=getIntent().getStringArrayListExtra("imgpath"); album=getIntent().getStringArrayListExtra("album"); artist=getIntent().getStringArrayListExtra("artist"); // ArrayAdapter<String> aa=new ArrayAdapter<String>(this,R.layout.row,R.id.text2,al); //lv.setAdapter(aa); try{ lv.setAdapter( new styleadapter(this,R.layout.row, R.id.text2,al)); }catch(Throwable e) { Log.e("openaudio error",""+e.toString()); goBlooey(e); } lv.setOnItemClickListener(new OnItemClickListener(){ @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3){ j=1; try{ d=arg2; String filep=filepath.get(d); String tit=al.get(d); String image=imgal.get(d); String singer=artist.get(d); String movie=album.get(d); sendpath(filep,tit,image,singer,movie); // getpath(n); }catch(Throwable t) { goBlooey(t); } } }); } @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); if(j==0) {i=new Intent(this,gorinkadashboard.class); startActivity(i);} } @Override protected void onResume() { // TODO Auto-generated method stub super.onResume(); j=0; } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode==KeyEvent.KEYCODE_SEARCH) { Log.i("go","go"); return true; } return(super.onKeyDown(keyCode, event)); } public void sendpath(String n,String nn,String image,String singer,String movie) { Intent ii=new Intent(this,MusicPlayerActivity.class); ii.putExtra("path",n); ii.putExtra("titletxt",nn); //ii.putStringArrayListExtra("playpath",filepath); ii.putExtra("pos",d); ii.putExtra("image",image); ii.putStringArrayListExtra("imagepath",imgal); ii.putStringArrayListExtra("filepath", filepath); ii.putStringArrayListExtra("imgal", imgal); ii.putExtra("movie" ,movie ); ii.putExtra("singer",singer); ii.putStringArrayListExtra("album", album); ii.putStringArrayListExtra("artist",artist); ii.putStringArrayListExtra("tittlearray",al); startActivity(ii); } class styleadapter extends ArrayAdapter<String> { Context context=null; public styleadapter(Context context, int resource, int textViewResourceId, List<String> objects) { super(context, resource, textViewResourceId, objects); this.context=context; } @Override public View getView(int position, View convertView, ViewGroup parent) { final int i=position; LayoutInflater inflater = ((Activity) context).getLayoutInflater(); View v = inflater.inflate(R.layout.row, null); tv=(TextView)v.findViewById(R.id.text2); albumtext=(TextView)v.findViewById(R.id.text3); artisttext=(TextView)v.findViewById(R.id.text1); tv.setText(al.get(i)); albumtext.setText(album.get(i)); artisttext.setText(artist.get(i)); final ImageView im=(ImageView)v.findViewById(R.id.image); s="http://www.gorinka.com/"+imgal.get(i); // displyimg(s,v); // new imageloader(s,im); String imgPath=s; AsyncImageLoaderv asyncImageLoaderv=new AsyncImageLoaderv(); Bitmap cachedImage = asyncImageLoaderv.loadDrawable(imgPath, new AsyncImageLoaderv.ImageCallback() { public void imageLoaded(Bitmap imageDrawable, String imageUrl) { im.setImageBitmap(imageDrawable); } }); im.setImageBitmap(cachedImage); return v; } } public class imageloader implements Runnable{ private String ss; //private View v; //private View v2; private ImageView im; public imageloader(String s, ImageView im) { this.ss=s; //this.v2=v2; this.im=im; Thread thread = new Thread(this); thread.start(); } public void run(){ try { // URL url = new URL(ss); // URLConnection conn = url.openConnection(); // conn.connect(); HttpGet httpRequest = null; httpRequest = new HttpGet(ss); HttpClient httpclient = new DefaultHttpClient(); HttpResponse response = (HttpResponse) httpclient.execute(httpRequest); HttpEntity entity = response.getEntity(); BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity); InputStream is = bufHttpEntity.getContent(); // BufferedInputStream bis = new BufferedInputStream(is); Bitmap bm = BitmapFactory.decodeStream(is); Log.d("img","img"); // bis.close(); is.close(); im.setImageBitmap(bm); // im.forceLayout(); // v2.postInvalidate(); // v2.requestLayout(); } catch (Exception t) { Log.e("bitmap url", "Exception in updateStatus()", t); //goBlooey(t); // throw new RuntimeException(t); } } } private void goBlooey(Throwable t) { AlertDialog.Builder builder=new AlertDialog.Builder(this); builder .setTitle("Exception!") .setMessage(t.toString()) .setPositiveButton("OK", null) .show(); } } I have created the SongList.java, SongsAdapter.java and also SongsAdapterView.java. Their code is... public class SongsList { private String titleName; private String movieName; private String singerName; private String imagePath; private String mediaPath; // Constructor for the SongsList class public SongsList(String titleName, String movieName, String singerName,String imagePath,String mediaPath ) { super(); this.titleName = titleName; this.movieName = movieName; this.singerName = singerName; this.imagePath = imagePath; this.mediaPath = mediaPath; } public String gettitleName() { return titleName; } public void settitleName(String titleName) { this.titleName = titleName; } public String getmovieName() { return movieName; } public void setmovieName(String movieName) { this.movieName = movieName; } public String getsingerName() { return singerName; } public void setsingerName(String singerName) { this.singerName = singerName; } public String getimagePath() { return imagePath; } public void setimagePath(String imagePath) { this.imagePath = imagePath; } public String getmediaPath() { return mediaPath; } public void setmediaPath(String mediaPath) { this.mediaPath = mediaPath; } } public class SongsAdapter extends BaseAdapter{ private Context context; private List<SongsList> listSongs; public SongsAdapter(Context context, List<SongsList> listPhonebook){ this.context = context; this.listSongs = listSongs; } public int getCount() { return listSongs.size(); } public Object getItem(int position) { return listSongs.get(position); } public long getItemId(int position) { return position; } public View getView(int position, View view, ViewGroup viewGroup) { SongsList entry = listSongs.get(position); return new SongsAdapterView(context,entry); } } public SongsAdapterView(Context context, SongsList entry) { super(context); this.setOrientation(VERTICAL); this.setTag(entry); // TODO Auto-generated constructor stub View v = inflate(context, R.layout.row, null); TextView tvTitle = (TextView)v.findViewById(R.id.text2); tvTitle.setText(entry.gettitleName()); TextView tvMovie = (TextView)v.findViewById(R.id.text3); tvTitle.setText(entry.getmovieName()); TextView tvSinger = (TextView)v.findViewById(R.id.text1); tvTitle.setText(entry.getsingerName()); addView(v); } } Can anyone please tell me how to display the list using custom lists and custom adapters using the code above???

    Read the article

  • iPod library song path access

    - by Narendra Kumar
    I studied a lot but did not find any good answer. My problem is i am calculating beats per minute of song.I used Bass api for that, now problem is i am able to get bpm of a file which i have in my resource folder but i have to get bpm of all songs of iPod library. I am getting path of song from MPMediaItemPropertyAssetURL property of MpMediaItem but when passing this one in api api is saying stream cant load BASS_StreamCreateFile(). In my point of view i am not getting right path of song. How can we access valid path? Did any one access ipod library song with external api? Please help me . Thanks CODE IS THIS NSURL *assetURL = [song valueForProperty:MPMediaItemPropertyAssetURL]; NSString *respath = [NSString stringWithFormat:@"%@",[assetURL absoluteString]]; BASS_SetConfig(BASS_CONFIG_IOS_MIXAUDIO, 0); // Disable mixing. To be called before BASS_Init. if (HIWORD(BASS_GetVersion()) != BASSVERSION) { NSLog(@"An incorrect version of BASS was loaded"); } // Initialize default device. if (!BASS_Init(-1, 44100, 0, NULL, NULL)) { //textView.text = [NSString stringWithFormat:@"%@ CAN'T Load Stream",textView.text]; } DWORD chan1; if(!(chan1=BASS_StreamCreateFile(FALSE, [respath UTF8String], 0, 0, BASS_SAMPLE_LOOP))) { NSLog(@"Can't load stream!"); textView.text = [NSString stringWithFormat:@"%@ not loading...",textView.text]; } mainStream=BASS_StreamCreateFile(FALSE, [respath cStringUsingEncoding:NSUTF8StringEncoding], 0, 0, BASS_SAMPLE_FLOAT|BASS_STREAM_PRESCAN|BASS_STREAM_DECODE); float playBackDuration=BASS_ChannelBytes2Seconds(mainStream, BASS_ChannelGetLength(mainStream, BASS_POS_BYTE)); NSLog(@"Play back duration is %f",playBackDuration); HSTREAM bpmStream=BASS_StreamCreateFile(FALSE, [respath UTF8String], 0, 0, BASS_STREAM_PRESCAN|BASS_SAMPLE_FLOAT|BASS_STREAM_DECODE); //BASS_ChannelPlay(bpmStream,FALSE); BpmValue= BASS_FX_BPM_DecodeGet(bpmStream,0.0, playBackDuration, MAKELONG(45,256), BASS_FX_BPM_MULT2| BASS_FX_BPM_MULT2 | BASS_FX_FREESOURCE, (BPMPROCESSPROC*)proc); textView.text = [NSString stringWithFormat:@"%@ %f",textView.text,BpmValue];

    Read the article

  • Android - attach data to views

    - by Leonti
    Hi! In my application I create dynamic rows in table much as in this tutorial: http://en.androidwiki.com/wiki/Dynamically_adding_rows_to_TableLayout for(int i = startDay; i < startDay + 7; i++){ /* Create a TextView to be the row-content. */ TextView day = new TextView(this); day.setText(Integer.toString(i)); day.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); day.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Log.i("Listener: ", "Click"); } So now when I click on a TextView I can register click event, but how do I determine which TextView was clicked? Not just an object which I get with an event but data like which day number was clicked? Ideally I would want to have data attached to every view I create dynamically. Something like data() method in Javascript jQuery. Right now I can see only 1 way to solve this - while creating TextView add id with data and when clicked - get id back and parse it to get my data. But it strikes me as ugly approach. Is there a way to attach arbitrary data to android views?

    Read the article

  • I can not get the text from a selected item in a listview...pleeeeasss help.

    - by Miguel
    I always get an ClassCastException error... i do not what else to do... - I'm using a data biding concept to populated the listview from a sqlite3 database. - I just want to get the selected item text after a long press click. This is the code of the activity: public class ItemConsultaGastos extends ListActivity { private DataHelper dh ; TextView seleccion; private static String[] FROM = {DataHelper.MES, DataHelper.ANO}; private static int[] TO = {R.id.columnaMes, R.id.columnaAno }; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.muestrafechas); this.dh = new DataHelper(this); Cursor cursor = dh.selectAllMeses(); startManagingCursor(cursor); this.mostrarFechas(cursor); ListView lv = getListView(); lv.setOnItemLongClickListener(new OnItemLongClickListener(){ @Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1,int row, long arg3) { //here is where i got the classCastException. String[] tmp = (String[]) arg0.getItemAtPosition(row); //tmp[0] ist the Text of the first TextView displayed by the clicked ListItem Log.w("Gastos: ", "El texto: " + tmp[0].toString()); return true; } }); } private void mostrarFechas(Cursor cursor) { SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,R.layout.muestrafechasitem,cursor, FROM, TO); setListAdapter(adapter); } } ///// This is the xml where a define the rows to show on the listview <TextView android:id="@+id/espacio" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" " /> <TextView android:id="@+id/columnaAno" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20sp" android:layout_toRightOf="@+id/espacio"/> <TextView android:id="@+id/separador1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" -- " android:layout_toRightOf="@+id/columnaAno" android:textSize="20sp" /> <TextView android:id="@+id/columnaMes" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_toRightOf="@+id/separador1" android:textSize="20sp"/>

    Read the article

  • Null Exception RelativeLayout

    - by theblixguy
    I am trying to remove objects from my relative layout and replace the background with another image but I get a java.lang.NullPointerException on this line: RelativeLayout ths = (RelativeLayout)findViewById(R.layout.activity_main); Below is my code: package com.ssrij.qrmag; import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.view.animation.Animation; import android.view.animation.TranslateAnimation; import android.view.animation.Animation.AnimationListener; import android.widget.Button; import android.widget.RelativeLayout; import android.widget.TextView; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Initialize animations Animation a = new TranslateAnimation(1000,0,0,0); Animation a1 = new TranslateAnimation(1000,0,0,0); Animation a2 = new TranslateAnimation(1000,0,0,0); Animation a3 = new TranslateAnimation(1000,0,0,0); // Set animation durations (ms) a.setDuration(1200); a1.setDuration(1400); a2.setDuration(1600); a3.setDuration(1800); // Get a reference to the objects we want to apply the animation to final TextView v = (TextView)findViewById(R.id.textView1); final TextView v1 = (TextView)findViewById(R.id.textView2); final TextView v2 = (TextView)findViewById(R.id.TextView3); final Button v3 = (Button)findViewById(R.id.tap_scan); // Clear existing animations, just in case... v.clearAnimation(); v1.clearAnimation(); v2.clearAnimation(); v3.clearAnimation(); // Start animating v.startAnimation(a); v1.startAnimation(a1); v2.startAnimation(a2); v3.startAnimation(a3); a1.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { // TODO Auto-generated method stub } @Override public void onAnimationRepeat(Animation animation) { // TODO Auto-generated method stub } @Override public void onAnimationEnd(Animation animation) { v.setVisibility(View.INVISIBLE); v1.setVisibility(View.INVISIBLE); v2.setVisibility(View.INVISIBLE); v3.setVisibility(View.INVISIBLE); RelativeLayout ths = (RelativeLayout)findViewById(R.layout.activity_main); ths.setBackgroundResource(R.drawable.blurbg); } }); } public void ScanQr(View v) { // Open the QR Scan page Intent a = new Intent(MainActivity.this, ScanActivity.class); startActivity(a); } } Is there anything that I am doing wrong?

    Read the article

  • [Android] Show default selection color for custom listview

    - by Diego
    Hello, I have a listview with a custom BaseAdapter. Each row of the listview has a TextView and a CheckBox. The problem is when I click (or touch) any row, the textview foreground becomes gray, instead of the default behavior (background - green, textview foreground - white). Here is the code: row.xml: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" style="@style/layout"> <TextView android:id="@+id/main_lv_item_textView" style="@style/textViewBig" android:layout_alignParentLeft="true"/> <CheckBox android:id="@+id/main_lv_item_checkBox" style="@style/checkBox" android:layout_width="wrap_content" android:layout_alignParentRight="true"/> </RelativeLayout> Custom Adapter: public class CustomAdapter extends BaseAdapter { private List<Profile> profiles; private LayoutInflater inflater; private TextView tvName; private CheckBox cbEnabled; public CustomAdapter(List<Profile> profiles) { this.profiles = profiles; inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } public int getCount() { return profiles.size(); } public Object getItem(int position) { return profiles.get(position); } public long getItemId(int position) { return position; } public View getView(final int position, View convertView, ViewGroup parent) { View row = inflater.inflate(R.layout.main_lv_item, null); final Profile profile = profiles.get(position); tvName = (TextView) row.findViewById(R.id.main_lv_item_textView); registerForContextMenu(tvName); cbEnabled = (CheckBox) row.findViewById(R.id.main_lv_item_checkBox); tvName.setText(profile.getName()); if (profile.isEnabled()) { cbEnabled.setChecked(true); } tvName.setOnClickListener(new OnClickListener() { public void onClick(View v) { Bundle bundle = new Bundle(); bundle.putString(PROFILE_NAME_KEY, profile.getName()); Intent intent = new Intent(context, GuiProfile.class); intent.putExtras(bundle); startActivity(intent); } }); tvName.setOnLongClickListener(new OnLongClickListener() { public boolean onLongClick(View v) { selectedProfileName = ((TextView) v).getText().toString(); return false; } }); cbEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (!profile.isEnabled()) { for (Profile profile : profiles) { if (profile.isEnabled()) { profile.setEnabled(false); Database.getInstance().storeProfile(profile); } } } profile.setEnabled(isChecked); Database.getInstance().storeProfile(profile); updateListView(); } }); return row; } } Any help would be appreciated.

    Read the article

  • Error reading values from dynamically created table rows in Android

    - by jaymo
    So I have a couple of dynamically created tablerows.Each TableRow has a couple of Textviews.I have a button that on clicked should get all the values of the second and third textviews in each Tablerow in the Table. I have tried to do this using the code below mSubmitOrders.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if(mTable.getChildCount()>1){ for(int i = 0; i < mTable.getChildCount(); i++){ TableRow tr = (TableRow)mTable.getChildAt(i); TextView code = (TextView) tr.getChildAt(1); TextView quantity = (TextView) tr.getChildAt(2); String Scode = code.getText().toString(); Log.i("TAG", Scode); String Squantity = quantity.getText().toString(); Log.i("TAG", Squantity); } } But I get the below errors (Logcat below). Assistance required 10-22 09:00:16.345: E/AndroidRuntime(4495): FATAL EXCEPTION: main 10-22 09:00:16.345: E/AndroidRuntime(4495): java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.TextView 10-22 09:00:16.345: E/AndroidRuntime(4495): at com.symetry.myitprovider.ui.actual$4.onClick(actual.java:173) 10-22 09:00:16.345: E/AndroidRuntime(4495): at android.view.View.performClick(View.java:3131) 10-22 09:00:16.345: E/AndroidRuntime(4495): at android.view.View$PerformClick.run(View.java:12035) 10-22 09:00:16.345: E/AndroidRuntime(4495): at android.os.Handler.handleCallback(Handler.java:587) 10-22 09:00:16.345: E/AndroidRuntime(4495): at android.os.Handler.dispatchMessage(Handler.java:92) 10-22 09:00:16.345: E/AndroidRuntime(4495): at android.os.Looper.loop(Looper.java:132) 10-22 09:00:16.345: E/AndroidRuntime(4495): at android.app.ActivityThread.main(ActivityThread.java:4123) 10-22 09:00:16.345: E/AndroidRuntime(4495): at java.lang.reflect.Method.invokeNative(Native Method) 10-22 09:00:16.345: E/AndroidRuntime(4495): at java.lang.reflect.Method.invoke(Method.java:491) 10-22 09:00:16.345: E/AndroidRuntime(4495): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844) 10-22 09:00:16.345: E/AndroidRuntime(4495): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602) 10-22 09:00:16.345: E/AndroidRuntime(4495): at dalvik.system.NativeStart.main(Native Method) EDIT: I have modified my code and now there is no error..but its not working as needed.. The new code is as below.. mSubmitOrders.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if(mTable.getChildCount()>1){ for(int i = 0; i < mTable.getChildCount(); i++){ //TODO: Figure out how to do this well LinearLayout LL = (LinearLayout)mTable.getChildAt(i); View x = ((View)(LL.getParent()).getParent()); Log.i("TAG", "Past view"); TextView code = (TextView)((ViewGroup) x).getChildAt(2); String Scode = code.getText().toString(); Log.i("TAG", Scode); } But thing is its not getting the texview from TableLayout's Table Row..its getting a different one...the one I have circled in the picture ![Error]:http://semasoftltd.com/error.png

    Read the article

  • Video Recording Not Working in ICS

    - by Nirav Ranpara
    I have implement code Record video in Android Phone . This code is working in 2.2 , 2.3 . not in ICS But when I checked in ICS code is not working ? here I posted code and xml file. videorecord.java import java.io.File; import java.io.IOException; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.hardware.Camera; import android.media.CamcorderProfile; import android.media.MediaRecorder; import android.os.Bundle; import android.os.CountDownTimer; import android.os.Environment; import android.util.Log; import android.view.Display; import android.view.KeyEvent; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.EditText; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; public class videorecord extends Activity{ SharedPreferences.Editor pre; String filename; CountDownTimer t; private Camera myCamera; private MyCameraSurfaceView myCameraSurfaceView; private MediaRecorder mediaRecorder; Integer cnt=0; LinearLayout myButton; TextView myButton1; SurfaceHolder surfaceHolder; boolean recording; private TextView txtcount; private ImageView btnplay; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); recording = false; setContentView(R.layout.videorecord); init(); myCamera = getCameraInstance(); if(myCamera == null){ } myCameraSurfaceView = new MyCameraSurfaceView(this, myCamera); FrameLayout myCameraPreview = (FrameLayout)findViewById(R.id.videoview); Display display = getWindowManager().getDefaultDisplay(); int width = display.getWidth(); int height = display.getHeight(); myCameraSurfaceView.setLayoutParams(new LinearLayout.LayoutParams(width, height-60)); myCameraPreview.addView(myCameraSurfaceView); myButton = (LinearLayout)findViewById(R.id.mybutton); btnplay.setOnClickListener(myButtonOnClickListener); } private void init() { txtcount = (TextView) findViewById(R.id.txtcounter); //myButton1 = (TextView) findViewById(R.id.mybutton1); btnplay = (ImageView)findViewById(R.id.btnplay); t = new CountDownTimer( Long.MAX_VALUE , 1000) { @Override public void onTick(long millisUntilFinished) { cnt++; String time = new Integer(cnt).toString(); long millis = cnt; int seconds = (int) (millis / 60); int minutes = seconds / 60; seconds = seconds % 60; txtcount.setText(String.format("%d:%02d:%02d", minutes, seconds,millis)); } @Override public void onFinish() { } }; } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK)) { if(recording) { new AlertDialog.Builder(videorecord.this).setTitle("Do you want to save Video ?") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { filename(); //finish(); } }).setNegativeButton("Cancle", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }).show(); } else { if ((keyCode == KeyEvent.KEYCODE_BACK)) { //Intent homeIntent= new Intent(Intent.ACTION_MAIN); //homeIntent.addCategory(Intent.CATEGORY_HOME); //homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); //startActivity(homeIntent); //this.finishActivity(1); finish(); } //moveTaskToBack(true); // finish(); return super.onKeyDown(keyCode, event); } } else { // Toast.makeText(getApplicationContext(), "asd", Toast.LENGTH_LONG).show(); android.os.Process.killProcess(android.os.Process.myPid()) ; } return super.onKeyDown(keyCode, event); } ImageView.OnClickListener myButtonOnClickListener = new ImageView.OnClickListener(){ public void onClick(View v) { if(recording){ Log.e("Record error", "error in recording ."); mediaRecorder.stop(); t.cancel(); filename(); releaseMediaRecorder(); }else{ releaseCamera(); Log.e("Record Stop error", "error in recording ."); // if(!prepareMediaRecorder()){ prepareMediaRecorder(); finish(); } mediaRecorder.start(); recording = true; // myButton1.setText("STOP Recording"); // btnplay.setImageResource(android.R.drawable.ic_media_pause); btnplay.setImageResource(R.drawable.stoprec); t.start(); } }}; private Camera getCameraInstance(){ Camera c = null; try { c = Camera.open(); } catch (Exception e){ } return c; } private void filename() { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Save Video"); alert.setMessage("Enter File Name"); final EditText input = new EditText(this); alert.setView(input); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { if(input.getText().length()>=1) { filename = input.getText().toString(); File sdcard = new File(Environment.getExternalStorageDirectory() + "/VideoRecord"); File from = new File(sdcard,"null.mp4"); File to = new File(sdcard,filename+".mp4"); from.renameTo(to); SharedPreferences sp = videorecord.this.getSharedPreferences("data", MODE_WORLD_WRITEABLE); pre = sp.edit(); pre.clear(); pre.commit(); pre.putString("lastvideo", filename+".mp4"); pre.commit(); //btnplay.setImageResource(android.R.drawable.ic_media_play); btnplay.setImageResource(R.drawable.startrec); // Intent intent = new Intent(videorecord.this,StopVidoWatch_Activity.class); // startActivity(intent); Intent myIntent = new Intent(getApplicationContext(), StopVidoWatch_Activity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(myIntent); } else { filename(); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Intent intent = new Intent(videorecord.this,StopVidoWatch_Activity.class); // startActivity(intent); File file = new File(Environment.getExternalStorageDirectory() + "/VideoRecord/null.mp4"); //boolean deleted = file.delete(); file.delete(); finish(); } }); alert.show(); } private boolean prepareMediaRecorder(){ myCamera = getCameraInstance(); mediaRecorder = new MediaRecorder(); myCamera.unlock(); mediaRecorder.setCamera(myCamera); mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER); mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH)); File folder = new File(Environment.getExternalStorageDirectory() + "/VideoRecord"); boolean success = false; if (!folder.exists()) { success = folder.mkdir(); } if (!success) { } else { } mediaRecorder.setOutputFile("/sdcard/VideoRecord/"+filename+".mp4"); mediaRecorder.setMaxDuration(60000); mediaRecorder.setMaxFileSize(5000000); Display display = getWindowManager().getDefaultDisplay(); int width = display.getHeight(); int height = display.getWidth(); String s = new String(); s= s.valueOf(width); String s1 = new String(); s1= s1.valueOf(height); // Toast.makeText(videorecord.this, "Width : " + s , Toast.LENGTH_LONG).show(); // Toast.makeText(videorecord.this, "Height : " + s1 , Toast.LENGTH_LONG).show(); mediaRecorder.setVideoSize(height, width); mediaRecorder.setPreviewDisplay(myCameraSurfaceView.getHolder().getSurface()); try { mediaRecorder.prepare(); } catch (IllegalStateException e) { releaseMediaRecorder(); return false; } catch (IOException e) { releaseMediaRecorder(); return false; } return true; } @Override protected void onPause() { super.onPause(); releaseMediaRecorder(); releaseCamera(); } private void releaseMediaRecorder() { if (mediaRecorder != null) { mediaRecorder.reset(); mediaRecorder.release(); mediaRecorder = null; myCamera.lock(); } } private void releaseCamera(){ if (myCamera != null){ myCamera.release(); myCamera = null; } } public class MyCameraSurfaceView extends SurfaceView implements SurfaceHolder.Callback{ private SurfaceHolder mHolder; private Camera mCamera; public MyCameraSurfaceView(Context context, Camera camera) { super(context); mCamera = camera; mHolder = getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } public void surfaceChanged(SurfaceHolder holder, int format, int weight, int height) { if (mHolder.getSurface() == null){ return; } try { mCamera.stopPreview(); } catch (Exception e){ } try { mCamera.setPreviewDisplay(mHolder); mCamera.startPreview(); } catch (Exception e){ } } public void surfaceCreated(SurfaceHolder holder) { try { mCamera.setPreviewDisplay(holder); mCamera.startPreview(); } catch (IOException e) { } } public void surfaceDestroyed(SurfaceHolder holder) { } } } videorecord.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" > <FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent" > <FrameLayout android:id="@+id/videoview" android:layout_width="fill_parent" android:layout_height="fill_parent"></FrameLayout> <LinearLayout android:id="@+id/mybutton" android:layout_width="fill_parent" android:layout_marginBottom="0dip" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_weight="0" > <!-- <TextView android:text="START Recording" android:id="@+id/mybutton1" android:layout_height="wrap_content" android:layout_width="wrap_content" style="@style/savestyle" android:layout_weight="1" android:gravity="left" > </TextView> --> <ImageView android:layout_height="wrap_content" android:id="@+id/btnplay" android:padding="5dip" android:background="#A0000000" android:textColor="#ffffffff" android:layout_width="wrap_content" android:src="@drawable/startrec" /> </LinearLayout> <TextView android:text="00:00:00" android:id="@+id/txtcounter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right|bottom" android:padding="5dip" android:background="#A0000000" android:textColor="#ffffffff" /> </FrameLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/bgcolor" > <LinearLayout android:layout_above="@+id/mybutton" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" > </LinearLayout> </RelativeLayout> </LinearLayout>

    Read the article

  • Pause and Resume and get the value of a countdown timer by savedInstanceState [closed]

    - by Catherine grace Balauro
    I have developed a countdown timer and I am not sure how to pause and resume the timer as the TextView for the timer is being clicked. Click to start then click again to pause and to resume, click again the timer's text view. This is my code: Timer = (TextView)this.findViewById(R.id.time); //TIMER Timer.setOnClickListener(TimerClickListener); counter = new MyCount(600000, 1000); }//end of create private OnClickListener TimerClickListener = new OnClickListener() { public void onClick(View v) { updateTimeTask(); } private void updateTimeTask() { if (decision==0){ counter.start(); decision=1;} else if(decision==2){ counter.onResume1(); decision=1; } else{ counter.onPause1(); decision=2; }//end if }; }; class MyCount extends CountDownTimer { public MyCount(long millisInFuture, long countDownInterval) { super(millisInFuture, countDownInterval); }//MyCount public void onResume1(){ onResume(); } public void onPause1() { onPause();} public void onFinish() { Timer.setText("00:00"); p1++; if (p1<=4){ TextView PScore = (TextView) findViewById(R.id.pscore); PScore.setText(p1 + ""); }//end if }//finish public void onTick(long millisUntilFinished) { Integer milisec = new Integer(new Double(millisUntilFinished).intValue()); Integer cd_secs = milisec / 1000; Integer minutes = (cd_secs % 3600) / 60; Integer seconds = (cd_secs % 3600) % 60; Timer.setText(String.format("%02d", minutes) + ":" + String.format("%02d", seconds)); //long timeLeft = millisUntilFinished / 1000; }//on tick }//class MyCount protected void onResume() { super.onResume(); //handler.removeCallbacks(updateTimeTask); //handler.postDelayed(updateTimeTask, 1000); }//onResume @Override protected void onPause() { super.onPause(); //do stuff }//onPause I am only beginner in android programming and I don't know how to get the value of the countdown timer using savedInstanceState. How do I do this?

    Read the article

  • how to use rsa in application i found code but dont know how to implement [closed]

    - by Smart Guy
    HOW TO I USE THIS RSA http://xtrace.blogspot.com/2012/03/rsa-demo-example.html?showComment=1349091173502#c199333123405145467 TUTOTIAL CODE IN MY LOGIN CODE BELOW I found code but dnt know how to implement public class LoginScreen extends Activity implements OnClickListener{ public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.login.xml); TextView lblMobileNo = (TextView)findViewById(R.id.lblMobileNo); lblMobileNo.setTextColor(getResources().getColor(R.color.text_color_red)); mobile = (EditText)findViewById(R.id.txtMobileNo); TextView lblPinNo = (TextView)findViewById(R.id.lblPinNo); lblPinNo.setTextColor(getResources().getColor(R.color.text_color_red)); pin = (EditText)findViewById(R.id.txtPinNo); btnLogin = (Button)findViewById(R.id.btnLogin); btnClear = (Button)findViewById(R.id.btnClear); btnLogin.setOnClickListener(new OnClickListener() { public void onClick(View view) { postLoginData(); } }); btnClear.setOnClickListener(new OnClickListener() { public void onClick(View v) { cleartext(); } }); /* btnClear.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { } }); */ } public void postLoginData() { Intent i = new Intent(this.getApplicationContext(),NEWCLASS.class); Bundle bundle = new Bundle(); bundle.putString("mno", mobile.getText().toString()); bundle.putString("pinno", pin.getText().toString()); i.putExtras(bundle); startActivity(i); } } @Override public void onClick(View v) { } public void cleartext() { { pin.setText("") ; mobile.setText(""); } } }

    Read the article

  • Android How do i overwrite the filter for my ArrayAdapter?

    - by alan
    Hey guys my first post here... Im trying to write a custom filter to filter the arraylist in my arrayadapter such that my listview is filtered when i click on the button. For instance when i click on my button public void onClick(View arg0) { String abc = "abc"; m_adapter.getFilter().filter(abc); } However, when i click on my button, my app terminate unexpectedly. Here is my code for the arrayadapter and filter. Please help me. package com.ntu.rosemobile.searchlist; public class ResultsAdapter extends ArrayAdapter<SearchItem> implements Filterable{ public ArrayList<SearchItem> subItems; public ArrayList<SearchItem> allItems; private LayoutInflater inflater; private PTypeFilter filter; public ResultsAdapter(Context context, int textViewResourceId, ArrayList<SearchItem> items) { super(context, textViewResourceId, items); this.subItems = items; this.allItems = this.subItems; inflater= LayoutInflater.from(context); } @Override public Filter getFilter() { if (filter == null){ filter = new PTypeFilter(); } return filter; } //@Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { v = inflater.inflate(R.layout.listrow, null); } SearchItem o = subItems.get(position); if (o != null) { TextView pname = (TextView) v.findViewById(R.id.productname); TextView neg = (TextView) v.findViewById(R.id.negNum); TextView pos = (TextView) v.findViewById(R.id.posNum); TextView neu = (TextView) v.findViewById(R.id.neuNum); WebImageView productPhoto = (WebImageView)v.findViewById(R.id.pPhoto); if(productPhoto!=null){ productPhoto.setImageUrl(o.getImageUrl().toString()); productPhoto.loadImage(); } if(pname!= null){ pname.setText(o.getProductName().toString()); } if (neg != null) { String a = "" + o.getNegativeReviews(); neg.setText(a); } if(neu != null){ String a = "" + o.getNeutralReviews(); neu.setText(a); } if(pos != null){ String a = "" + o.getPositiveReviews(); pos.setText(a); } } return v; } private class PTypeFilter extends Filter{ @SuppressWarnings("unchecked") @Override protected void publishResults(CharSequence prefix, FilterResults results) { // NOTE: this function is *always* called from the UI thread. subItems = (ArrayList<SearchItem>)results.values; notifyDataSetChanged(); } @SuppressWarnings("unchecked") protected FilterResults performFiltering(CharSequence prefix) { // NOTE: this function is *always* called from a background thread, and // not the UI thread. FilterResults results = new FilterResults(); ArrayList<SearchItem> i = new ArrayList<SearchItem>(); if (prefix!= null && prefix.toString().length() > 0) { for (int index = 0; index < allItems.size(); index++) { SearchItem si = allItems.get(index); if(si.getPType().compareTo(prefix.toString()) == 0){ i.add(si); } } results.values = i; results.count = i.size(); } else{ synchronized (allItems){ results.values = allItems; results.count = allItems.size(); } } return results; } } }

    Read the article

  • Programming an Android Button to update EditText views

    - by bergler77
    Ok guys, I have a button in android that i'm trying to use to update 8 EditText Views with different random numbers. Everything works up until I click the button. It appears I am missing a resource according to the debugger, but I'm not sure what. I've tried several different ways of implementing the button. Here is what I have after looking at several posts. import java.util.Random; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; public class MyCharNewChar extends MyCharActivity { private OnClickListener randomButtonListener = new OnClickListener(){ public void onClick(View v) { //Button creates a set of random numbers and updates the values //of the EditText views. Random rand = new Random(); int STR = 1 + rand.nextInt(12); int AGI = 1 + rand.nextInt(12); int DEX = 1 + rand.nextInt(12); int WIS = 1 + rand.nextInt(12); int INT = 1 + rand.nextInt(12); int CON = 1 + rand.nextInt(12); int HP = 1 + rand.nextInt(20); int AC = 1 + rand.nextInt(6); EditText str = (EditText) findViewById(R.id.str); str.setText(STR); EditText agi = (EditText) findViewById(R.id.agi); agi.setText(AGI); EditText dex = (EditText) findViewById(R.id.dex); dex.setText(DEX); EditText wis = (EditText) findViewById(R.id.wis); wis.setText(WIS); EditText intel = (EditText) findViewById(R.id.intel); intel.setText(INT); EditText con = (EditText) findViewById(R.id.con); con.setText(CON); EditText hp = (EditText) findViewById(R.id.baseHP); hp.setText(HP); EditText ac = (EditText) findViewById(R.id.baseAC); ac.setText(AC); } }; @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.newchar); Button randomButton = (Button) findViewById(R.id.randomButton); randomButton.setOnClickListener(randomButtonListener); } } Here is the xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linearlayoutNew1" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@drawable/background" > <TextView android:id="@+id/newCharLabel" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/new_character_screen" android:textSize="24dp" android:textColor="@color/splash" android:textStyle="bold" android:gravity="center"/> <TextView android:id="@+id/nameLabel" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/nameLabel" android:textSize="18dp" android:textColor="@color/splash"/> <EditText android:id="@+id/editText1" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:inputType="textPersonName" > <requestFocus /> </EditText> <TableLayout android:id="@+id/statsLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="5dp"> <TableRow android:id="@+id/tableRow01" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="5dp"> <TextView android:id="@+id/strLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/strLabel" android:textSize="18dp" android:textColor="@color/splash"/> <EditText android:id="@+id/str" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="3" android:inputType="number" /> <TextView android:id="@+id/agiLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/agiLabel" android:textSize="18dp" android:textColor="@color/splash"/> <EditText android:id="@+id/agi" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="3" android:inputType="number"/> <TextView android:id="@+id/dexLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/dexLabel" android:textSize="18dp" android:textColor="@color/splash"/> <EditText android:id="@+id/dex" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="3" android:inputType="number"/> </TableRow> <TableRow android:id="@+id/tableRow02" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="5dp"> <TextView android:id="@+id/intLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/intLabel" android:textSize="18dp" android:textColor="@color/splash"/> <EditText android:id="@+id/intel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="3" android:inputType="number"/> <TextView android:id="@+id/wisLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/wisLabel" android:textSize="18dp" android:textColor="@color/splash"/> <EditText android:id="@+id/wis" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="3" android:inputType="number"/> <TextView android:id="@+id/conLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/conLabel" android:textSize="18dp" android:textColor="@color/splash"/> <EditText android:id="@+id/con" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="3" android:inputType="number"/> </TableRow> </TableLayout> <LinearLayout android:id="@+id/linearlayoutNew02" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="5dp" android:gravity="center"> <TextView android:id="@+id/baseHPLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hpLabel" android:textSize="18dp" android:textColor="@color/splash"/> <EditText android:id="@+id/baseHP" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="3" android:inputType="number"/> <TextView android:id="@+id/baseACLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/acLabel" android:textSize="18dp" android:textColor="@color/splash"/> <EditText android:id="@+id/baseAC" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="3" android:inputType="number"/> </LinearLayout> <LinearLayout android:id="@+id/linearlayoutNew03" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/randomButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/randomButton" android:textSize="16dp" android:clickable="true"/> </LinearLayout> </LinearLayout> I have also tried setting the onClick in xml to setup a specific onClick method. Still the same error so I must have a problem elsewhere. Any suggestions would be great!

    Read the article

  • parseInt and viewflipper layout problems

    - by user1234167
    I have a problem with parseInt it throws the error: unable to parse 'null' as integer. My view flipper is also not working. Hopefully this is an easy enough question. Here is my activity: import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.InputSource; import org.xml.sax.XMLReader; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.ViewFlipper; import xml.parser.dataset; public class XmlParserActivity extends Activity implements OnClickListener { private final String MY_DEBUG_TAG = "WeatherForcaster"; // private dataset myDataSet; private LinearLayout layout; private int temp= 0; /** Called when the activity is first created. */ //the ViewSwitcher private Button btn; private ViewFlipper flip; // private TextView tv; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); layout=(LinearLayout)findViewById(R.id.linearlayout1); btn=(Button)findViewById(R.id.btn); btn.setOnClickListener(this); flip=(ViewFlipper)findViewById(R.id.flip); //when a view is displayed flip.setInAnimation(this,android.R.anim.fade_in); //when a view disappears flip.setOutAnimation(this, android.R.anim.fade_out); // String postcode = null; // public String getPostcode { // return postcode; // } //URL newUrl = c; // myweather.setText(c.toString()); /* Create a new TextView to display the parsingresult later. */ TextView tv = new TextView(this); // run(0); //WeatherApplicationActivity postcode = new WeatherApplicationActivity(); try { /* Create a URL we want to load some xml-data from. */ URL url = new URL("http://new.myweather2.com/developer/forecast.ashx?uac=gcV3ynNdoV&output=xml&query=G41"); //String url = new String("http://new.myweather2.com/developer/forecast.ashx?uac=gcV3ynNdoV&output=xml&query="+WeatherApplicationActivity.postcode ); //URL url = new URL(url); //url.toString( ); //myString(url.toString() + WeatherApplicationActivity.getString(postcode)); // url + WeatherApplicationActivity.getString(postcode); /* Get a SAXParser from the SAXPArserFactory. */ SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); /* Get the XMLReader of the SAXParser we created. */ XMLReader xr = sp.getXMLReader(); /* Create a new ContentHandler and apply it to the XML-Reader*/ handler myHandler = new handler(); xr.setContentHandler(myHandler); /* Parse the xml-data from our URL. */ xr.parse(new InputSource(url.openStream())); /* Parsing has finished. */ /* Our ExampleHandler now provides the parsed data to us. */ dataset parsedDataSet = myHandler.getParsedData(); /* Set the result to be displayed in our GUI. */ tv.setText(parsedDataSet.toString()); } catch (Exception e) { /* Display any Error to the GUI. */ tv.setText("Error: " + e.getMessage()); Log.e(MY_DEBUG_TAG, "WeatherQueryError", e); } temp = Integer.parseInt(xml.parser.dataset.getTemp()); if(temp <0){ //layout.setBackgroundColor(Color.BLUE); //layout.setBackgroundColor(getResources().getColor(R.color.silver)); findViewById(R.id.flip).setBackgroundColor(Color.BLUE); } else if(temp > 0 && temp < 9) { //layout.setBackgroundColor(Color.GREEN); //layout.setBackgroundColor(getResources().getColor(R.color.silver)); findViewById(R.id.flip).setBackgroundColor(Color.GREEN); } else { //layout.setBackgroundColor(Color.YELLOW); //layout.setBackgroundColor(getResources().getColor(R.color.silver)); findViewById(R.id.flip).setBackgroundColor(Color.YELLOW); } /* Display the TextView. */ this.setContentView(tv); } @Override public void onClick(View arg0) { // TODO Auto-generated method stub onClick(View arg0) { // TODO Auto-generated method stub flip.showNext(); //specify flipping interval //flip.setFlipInterval(1000); //flip.startFlipping(); } } this is my dataset: package xml.parser; public class dataset { static String temp = null; // private int extractedInt = 0; public static String getTemp() { return temp; } public void setTemp(String temp) { this.temp = temp; } this is my handler: public void characters(char ch[], int start, int length) { if(this.in_temp){ String setTemp = new String(ch, start, length); // myParsedDataSet.setTempUnit(new String(ch, start, length)); // myParsedDataSet.setTemp; } the dataset and handler i only pasted the code that involves the temp as i no they r working when i take out the if statement. However even then my viewflipper wont work. This is my main 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" android:id="@+id/linearlayout1" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="25dip" android:text="Flip Example" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="25dip" android:id="@+id/tv" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="25dip" android:text="Flip" android:id="@+id/btn" android:onClick="ClickHandler" /> <ViewFlipper android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/flip"> <LinearLayout 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:textSize="25dip" android:text="Item1a" /> </LinearLayout> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="25dip" android:id="@+id/tv2" /> </ViewFlipper> </LinearLayout> this is my logcat: 04-01 18:02:24.744: E/AndroidRuntime(7331): FATAL EXCEPTION: main 04-01 18:02:24.744: E/AndroidRuntime(7331): java.lang.RuntimeException: Unable to start activity ComponentInfo{xml.parser/xml.parser.XmlParserActivity}: java.lang.NumberFormatException: unable to parse 'null' as integer 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1830) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1851) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.app.ActivityThread.access$1500(ActivityThread.java:132) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.os.Handler.dispatchMessage(Handler.java:99) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.os.Looper.loop(Looper.java:150) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.app.ActivityThread.main(ActivityThread.java:4293) 04-01 18:02:24.744: E/AndroidRuntime(7331): at java.lang.reflect.Method.invokeNative(Native Method) 04-01 18:02:24.744: E/AndroidRuntime(7331): at java.lang.reflect.Method.invoke(Method.java:507) 04-01 18:02:24.744: E/AndroidRuntime(7331): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849) 04-01 18:02:24.744: E/AndroidRuntime(7331): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607) 04-01 18:02:24.744: E/AndroidRuntime(7331): at dalvik.system.NativeStart.main(Native Method) 04-01 18:02:24.744: E/AndroidRuntime(7331): Caused by: java.lang.NumberFormatException: unable to parse 'null' as integer 04-01 18:02:24.744: E/AndroidRuntime(7331): at java.lang.Integer.parseInt(Integer.java:356) 04-01 18:02:24.744: E/AndroidRuntime(7331): at java.lang.Integer.parseInt(Integer.java:332) 04-01 18:02:24.744: E/AndroidRuntime(7331): at xml.parser.XmlParserActivity.onCreate(XmlParserActivity.java:118) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1794) I hope I have given enough information about my problems. I will be extremely grateful if anyone can help me out.

    Read the article

  • Why are some of my view not aligned correctly at the bottom of my relative layout?

    - by Janusz
    I have problems getting some of my views aligned in a relative layout that I use inside a row of my listview. Here is a screenshot from the layout builder in Eclipse, this is what I think it should look like: The next image is from the emulator. Now the TestTestTest View is at the top and covers the name and distance Textviews. This is my layout: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="4dip"> <ImageView android:id="@+id/logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:adjustViewBounds="true" android:scaleType="centerInside" android:src="@drawable/icon" android:layout_centerVertical="true" android:layout_alignParentLeft="true" android:background="@color/green" /> <TextView android:id="@+id/distance" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Distance" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:paddingRight="4dip" android:background="#000000" /> <TextView android:id="@+id/name" android:layout_width="fill_parent" style="@style/ListHeadText" android:layout_height="wrap_content" android:text="Name" android:layout_alignTop="@id/distance" android:layout_toRightOf="@id/logo" android:layout_toLeftOf="@id/distance" android:gravity="clip_horizontal" android:lines="1" android:paddingLeft="4dip" android:background="@color/red" /> <TextView android:id="@+id/number" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Number" android:paddingRight="4dip" android:layout_alignRight="@id/distance" android:background="@color/darkred" android:layout_below="@id/distance" /> <TextView android:id="@+id/subcategory" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Subcategory" android:paddingLeft="4dip" android:layout_alignLeft="@id/name" android:lines="1" android:gravity="clip_horizontal" android:layout_below="@id/distance" android:background="@color/green" /> <TextView android:id="@+id/test" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="TestTestTest" android:paddingLeft="4dip" android:layout_alignParentBottom="true" android:gravity="bottom" android:background="@color/red" /> Shouldnt align_parent_bottom put the view at the bottom of the cell in the list?

    Read the article

  • Custom filtering in Android using ArrayAdapter

    - by Alxandr
    I'm trying to filter my ListView which is populated with this ArrayAdapter: package me.alxandr.android.mymir.adapters; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.Set; import me.alxandr.android.mymir.R; import me.alxandr.android.mymir.model.Manga; import android.content.Context; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Filter; import android.widget.SectionIndexer; import android.widget.TextView; public class MangaListAdapter extends ArrayAdapter<Manga> implements SectionIndexer { public ArrayList<Manga> items; public ArrayList<Manga> filtered; private Context context; private HashMap<String, Integer> alphaIndexer; private String[] sections = new String[0]; private Filter filter; private boolean enableSections; public MangaListAdapter(Context context, int textViewResourceId, ArrayList<Manga> items, boolean enableSections) { super(context, textViewResourceId, items); this.filtered = items; this.items = filtered; this.context = context; this.filter = new MangaNameFilter(); this.enableSections = enableSections; if(enableSections) { alphaIndexer = new HashMap<String, Integer>(); for(int i = items.size() - 1; i >= 0; i--) { Manga element = items.get(i); String firstChar = element.getName().substring(0, 1).toUpperCase(); if(firstChar.charAt(0) > 'Z' || firstChar.charAt(0) < 'A') firstChar = "@"; alphaIndexer.put(firstChar, i); } Set<String> keys = alphaIndexer.keySet(); Iterator<String> it = keys.iterator(); ArrayList<String> keyList = new ArrayList<String>(); while(it.hasNext()) keyList.add(it.next()); Collections.sort(keyList); sections = new String[keyList.size()]; keyList.toArray(sections); } } @Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if(v == null) { LayoutInflater vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.mangarow, null); } Manga o = items.get(position); if(o != null) { TextView tt = (TextView) v.findViewById(R.id.MangaRow_MangaName); TextView bt = (TextView) v.findViewById(R.id.MangaRow_MangaExtra); if(tt != null) tt.setText(o.getName()); if(bt != null) bt.setText(o.getLastUpdated() + " - " + o.getLatestChapter()); if(enableSections && getSectionForPosition(position) != getSectionForPosition(position + 1)) { TextView h = (TextView) v.findViewById(R.id.MangaRow_Header); h.setText(sections[getSectionForPosition(position)]); h.setVisibility(View.VISIBLE); } else { TextView h = (TextView) v.findViewById(R.id.MangaRow_Header); h.setVisibility(View.GONE); } } return v; } @Override public void notifyDataSetInvalidated() { if(enableSections) { for (int i = items.size() - 1; i >= 0; i--) { Manga element = items.get(i); String firstChar = element.getName().substring(0, 1).toUpperCase(); if(firstChar.charAt(0) > 'Z' || firstChar.charAt(0) < 'A') firstChar = "@"; alphaIndexer.put(firstChar, i); } Set<String> keys = alphaIndexer.keySet(); Iterator<String> it = keys.iterator(); ArrayList<String> keyList = new ArrayList<String>(); while (it.hasNext()) { keyList.add(it.next()); } Collections.sort(keyList); sections = new String[keyList.size()]; keyList.toArray(sections); super.notifyDataSetInvalidated(); } } public int getPositionForSection(int section) { if(!enableSections) return 0; String letter = sections[section]; return alphaIndexer.get(letter); } public int getSectionForPosition(int position) { if(!enableSections) return 0; int prevIndex = 0; for(int i = 0; i < sections.length; i++) { if(getPositionForSection(i) > position && prevIndex <= position) { prevIndex = i; break; } prevIndex = i; } return prevIndex; } public Object[] getSections() { return sections; } @Override public Filter getFilter() { if(filter == null) filter = new MangaNameFilter(); return filter; } private class MangaNameFilter extends Filter { @Override protected FilterResults performFiltering(CharSequence constraint) { // NOTE: this function is *always* called from a background thread, and // not the UI thread. constraint = constraint.toString().toLowerCase(); FilterResults result = new FilterResults(); if(constraint != null && constraint.toString().length() > 0) { ArrayList<Manga> filt = new ArrayList<Manga>(); ArrayList<Manga> lItems = new ArrayList<Manga>(); synchronized (items) { Collections.copy(lItems, items); } for(int i = 0, l = lItems.size(); i < l; i++) { Manga m = lItems.get(i); if(m.getName().toLowerCase().contains(constraint)) filt.add(m); } result.count = filt.size(); result.values = filt; } else { synchronized(items) { result.values = items; result.count = items.size(); } } return result; } @SuppressWarnings("unchecked") @Override protected void publishResults(CharSequence constraint, FilterResults results) { // NOTE: this function is *always* called from the UI thread. filtered = (ArrayList<Manga>)results.values; notifyDataSetChanged(); } } } However, when I call filter('test') on the filter nothing happens at all (or the background-thread is run, but the list isn't filtered as far as the user conserns). How can I fix this?

    Read the article

  • No resource found that matches given name in main.xml

    - by AndroidBeginner
    This is really starting to drive me crazy. <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@id+/textview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="@string/hello"/> Produces the following error message: "Error: no resource found that matches the given name (at 'id' with value '@id+/textview'). This is copy and pasted from the Android hello world example.

    Read the article

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