Search Results

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

Page 4/37 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • textview.selectedRange.location in UITextview show 2147483647

    - by Risma
    hi i have a textview and i want to get the selectedRange.location value from that textview. in the first time when the keyboard appear, the location value always show an integer point such as 110, or others. But if i dissappear the keyboard and then appear the keyboard again, the location value always show 2147483647. What is this 2147483647 mean and how to get the real location value? This is my code in the keyboard will appear method : -(void)keyboardWillAppear:(NSNotification *)notification { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:[[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]]; CGRect keyboardEndingUncorrectedFrame = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey ] CGRectValue]; CGRect keyboardEndingFrame = [self.view convertRect:keyboardEndingUncorrectedFrame fromView:nil]; [UIView commitAnimations]; NSRange selectedRange = textview.selectedRange; NSLog(@"selected Range location : %f", selectedRange.location); }

    Read the article

  • Android TextView Linkify problem with phone numbers and application version number

    - by Gaks
    I have a problem with TextView and autoLink feature. I have an about screen in my application with some information like support phone number, email address, website URL and application version in form like 01.01.01 After setting autoLink="all" on the textView, all values are linked fine - except that version number 01.01.01 is linked as the phone number as well. Is there some way to exclude this text fragment from linkifing?

    Read the article

  • TextView height

    - by user286919
    Hi Everybody, I want to get height of TextView and line number currently shown in that TextView. How can I do that can any body help me about this matter ?? Thanks

    Read the article

  • Vertical Seek not progress value not showing on MainActivity textView

    - by Raju Gujarati
    I am try to display the progress value of the seekBar but when it comes to the execution, there is no update on the value being display on the TextView. I wonder what alternatives than putting two classes onto one big class in order to archive this aim ? The below is my code VerticalSeekBar.java package com.example.imagerotation; import android.content.Context; import android.graphics.Canvas; import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.SeekBar; import android.widget.Toast; public class VerticalSeekBar extends SeekBar { public VerticalSeekBar(Context context) { super(context); } public VerticalSeekBar(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public VerticalSeekBar(Context context, AttributeSet attrs) { super(context, attrs); } protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(h, w, oldh, oldw); } @Override protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(heightMeasureSpec, widthMeasureSpec); setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth()); } protected void onDraw(Canvas c) { c.rotate(-90); c.translate(-getHeight(), 0); super.onDraw(c); } @Override public boolean onTouchEvent(MotionEvent event) { if (!isEnabled()) { return false; } switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_UP: int progress = getMax() - (int) (getMax() * event.getY() / getHeight()); setProgress(progress); onSizeChanged(getWidth(), getHeight(), 0, 0); //Toast.makeText(getContext(), String.valueOf(progress), Toast.LENGTH_SHORT).show(); break; case MotionEvent.ACTION_CANCEL: break; } return true; } } MainActvity.java package com.example.imagerotation; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.widget.TextView; public class MainActivity extends Activity { private VerticalSeekBar seek; private TextView by; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); seek = (VerticalSeekBar)findViewById(R.id.seekBar1); by = (TextView)findViewById(R.id.textView1); by.setText(String.valueOf(seek.getProgress())); } }

    Read the article

  • How to access a TextView element in a BroadcastReceiver

    - by ric03uec
    Hello, I am testing a simple widget in android and using Alarms to update a TextView at regular intervals. The problem is that in the BroadcastReceiver class I cannot access the TextView element, which I want to get updated when the alarm expires. The class is being called properly because the Toast i have put there is giving the appropriate message. The following code is from the class where I configure the widget and set the timers. public void onCreate(Bundle bundle) { super.onCreate(bundle); Intent intent = getIntent(); Bundle extras = intent.getExtras(); if(extras != null){ mWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(WidgetConfigure.this); RemoteViews views = new RemoteViews(WidgetConfigure.this.getPackageName(), R.layout.widget_layout); views.setTextViewText(R.id.quote, "Widget Loaded From Activity"); appWidgetManager.updateAppWidget(mWidgetId, views); setTimer(); //set the timers... setResult();// set the result... } } Now i want to update the same TextView when the BroadCastReceiver is called after the timer expires. I have tried the code provided in the ExampleAppWidget example provided in android api demos and that isnt working out. How can i set the required text? Thankx in advance

    Read the article

  • How to display strings in activity 3 from activity 1, 2? [migrated]

    - by user107160
    I need to get strings values from two different activities say activity1 and activity2, each activity should have maximum 4 edittext field..so totally eight fields should be displayed orderly in activity3. I have tried the code which is not displaying in the activity3. Look at code, Activity1 String namef = fname.getText().toString(); Intent first = new Intent(AssessmentActivity.this, Second.class); first.putExtra("list1", namef); startActivity(first); String namel = lname.getText().toString(); Intent second = new Intent(AssessmentActivity.this, Second.class); second.putExtra("list2", namel); startActivity(second); String phone = mob.getText().toString(); Intent third = new Intent(AssessmentActivity.this, Second.class); third.putExtra("list3", phone); startActivity(third); String mailid = email.getText().toString(); Intent fourth = new Intent(AssessmentActivity.this, Second.class); fourth.putExtra("list4", mailid); startActivity(fourth); Activity2 String cont = addr.getText().toString(); Intent fifth = new Intent(Second.this, Third.class); fifth.putExtra("list5", cont); startActivity(fifth); String db = dob.getText().toString(); Intent sixth = new Intent(Second.this, Third.class); sixth.putExtra("list6", db); startActivity(sixth); String nation = citizen.getText().toString(); Intent Seventh = new Intent(Second.this, Third.class); Seventh.putExtra("list7", nation); startActivity(Seventh); String subject = course.getText().toString(); Intent Eight = new Intent(Second.this, Third.class); Eight.putExtra("list8", subject); startActivity(Eight); *Activity3* TextView first = (TextView)findViewById(R.id.textView2); String fieldone = getIntent().getStringExtra("list1" ); first.setText(fieldone); TextView second = (TextView)findViewById(R.id.textView3); String fieldtwo = getIntent().getStringExtra("list2" ); second.setText(fieldtwo); TextView third = (TextView)findViewById(R.id.textView4); String fieldthree = getIntent().getStringExtra("list3" ); third.setText(fieldthree); TextView fourth = (TextView)findViewById(R.id.textView5); String fieldfour = getIntent().getStringExtra("list4" ); fourth.setText(fieldfour); TextView fifth = (TextView)findViewById(R.id.textView6); String fieldfive = getIntent().getStringExtra("list5" ); fifth.setText(fieldfive); TextView sixth = (TextView)findViewById(R.id.textView7); String fieldsix = getIntent().getStringExtra("list6" ); sixth.setText(fieldsix); TextView seventh = (TextView)findViewById(R.id.textView8); String fieldseven = getIntent().getStringExtra("list7" ); seventh.setText(fieldseven); TextView eight = (TextView)findViewById(R.id.textView3); String fieldeight = getIntent().getStringExtra("list8"); eight.setText(fieldeight);

    Read the article

  • android: customized text selector

    - by Yang
    I wanted to design a customized text selector that changed the text color when user clicks the TextView. But got the following error: java.lang.RuntimeException: Unable to start activity ComponentInfo{}: android.view.InflateException: Binary XML file line #55: Error inflating class here is what I have: res/text_selector.xml <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="false" android:state_focused="true" android:drawable="@color/black" /> <item android:state_pressed="true" android:drawable="@color/blue" /> <item android:state_focused="true" android:drawable="@color/black" /> </selector> layout/textview.xml <TextView android:id = "@+id/last_page_button" android:text="@string/last_page_button_string" android:gravity="center_horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#ffffff" android:textColor = "@drawable/text_selector" android:layout_weight="1" /> values/color.xml <resources> <color name="white">#ffffffff</color> <color name="black">#ff000000</color> <color name="blue">#ffccddff</color>

    Read the article

  • Android: how to make two TextViews placed in different lines if there is no enough space in one line

    - by bluebyte
    I'am trying to organize two TextViews to behave like that: So, if there is enough space for both TextViews in line, android should place them in line. If there is no enough space, the second TextView must be placed on a next line with right alignment. <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:id="@+id/takeoffCity" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/flightItem" /> <TextView android:id="@+id/landingCity" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/flightItem" /> </LinearLayout> <style name="flightItem" parent="@android:style/TextAppearance"> <item name="android:textSize">14dip</item> <item name="android:textColor">@color/flightItemFont</item> <item name="android:scrollHorizontally">true</item> <item name="android:textStyle">bold</item> </style>

    Read the article

  • How to know all id's that i have in the file main.xml in android?

    - by sgiro
    Hello guy's, i'm new at Android world, and i have a doubt, is there any method that give me the name of the id's i create in main.xml? For example i have this: main.xml <TextView android:id="@+id/text1" android:layout_width="70px" android:layout_height="70px" android:text="Google" /> <TextView android:id="@+id/text2" android:layout_width="70px" android:layout_height="70px" android:text="As" /> And what i want is the id name from the two TextView, is there any method that i can use in my class .java that give me for this example the id? In this case i want the (text1 and text2). Thanks and forgive mi English.

    Read the article

  • Android: onClick on LinearLayout with TextView and Button

    - by Terry
    I have a Fragment that uses the following XML layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/card" android:clickable="true" android:onClick="editActions" android:orientation="vertical" > <TextView android:id="@+id/title" style="@style/CardTitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:duplicateParentState="true" android:text="@string/title_workstation" /> <Button android:id="@+id/factory_button_edit" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:duplicateParentState="true" android:text="@string/label_edit" /> </LinearLayout> As you can see, I have an onClick parameter set on LinearLayout. Now on the TextView this one is triggered correctly, and on all empty area. Just on the Button it doesn't invoke the onClick method that I set. Is this normal? What do I have to do so that the onClick method is invoked everywhere on the LinearLayout?

    Read the article

  • Android Autolink to launch WebView

    - by Jason Kim
    Hi, I'm using autoLink="web" attribute in TextView to launch Browser. However, I want to launch the myActivity with WebView, when I click the links in TextView. Is is possible that catch the click event and invoke startActivity? Thanks in advance, Jason

    Read the article

  • Showing ImageView next to TextView in a ListView

    - by KDEx
    So I have a listview that is displaying correctly. When the item is "turned on" the text is white and when it's turned off it's grey. That part all functions great. However when I add the ImageView into the mix I get a null pointer exception. I don't understand why. I've tried using bitmaps as well and get the same problem. Here is some code: @Override public void bindView(View view, Context context, Cursor cursor) { TextView rRule = (TextView) view.findViewById(R.id.rule_text); TextView rType = (TextView) view.findViewById(R.id.rule_type); ImageView iChecked = (ImageView) view.findViewById(R.id.checkBox); String ruleName = cursor.getString(1); int ruleType = cursor.getInt(2); String ruleEnabled = cursor.getString(3); switch (ruleType) { /*...some irrelevant code */ } if (ruleEnabled.equals("true")) { rRule.setTypeface(null, Typeface.BOLD); rRule.setTextColor(Color.WHITE); iChecked.setVisibility(View.VISIBLE); //line 271 } else if (ruleEnabled.equals("false")) { rRule.setTypeface(null, Typeface.NORMAL); rRule.setTextColor(Color.GRAY); iChecked.setVisibility(View.GONE); } rRule.setText(ruleName); } Per request the error log: (Sorry was under the impression null pointers dont say anything helpful..I know the error is the imageview) 06-29 10:29:02.777: E/AndroidRuntime(29516): FATAL EXCEPTION: main 06-29 10:29:02.777: E/AndroidRuntime(29516): java.lang.NullPointerException 06-29 10:29:02.777: E/AndroidRuntime(29516): at com.company.app.DefaultRulesList$RulesAdapter.bindView(DefaultRulesList.java:271) 06-29 10:29:02.777: E/AndroidRuntime(29516): at com.company.app.DefaultRulesList$RulesAdapter.newView(DefaultRulesList.java:284) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.widget.CursorAdapter.getView(CursorAdapter.java:246) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.widget.AbsListView.obtainView(AbsListView.java:2033) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.widget.ListView.makeAndAddView(ListView.java:1772) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.widget.ListView.fillDown(ListView.java:672) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.widget.ListView.fillFromTop(ListView.java:732) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.widget.ListView.layoutChildren(ListView.java:1625) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.widget.AbsListView.onLayout(AbsListView.java:1863) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.view.View.layout(View.java:11278) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.view.ViewGroup.layout(ViewGroup.java:4224) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.widget.LinearLayout.onLayout(LinearLayout.java:1399) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.view.View.layout(View.java:11278) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.view.ViewGroup.layout(ViewGroup.java:4224) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.widget.FrameLayout.onLayout(FrameLayout.java:431) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.view.View.layout(View.java:11278) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.view.ViewGroup.layout(ViewGroup.java:4224) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.widget.LinearLayout.onLayout(LinearLayout.java:1399) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.view.View.layout(View.java:11278) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.view.ViewGroup.layout(ViewGroup.java:4224) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.widget.FrameLayout.onLayout(FrameLayout.java:431) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.view.View.layout(View.java:11278) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.view.ViewGroup.layout(ViewGroup.java:4224) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1489) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.os.Handler.dispatchMessage(Handler.java:99) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.os.Looper.loop(Looper.java:137) 06-29 10:29:02.777: E/AndroidRuntime(29516): at android.app.ActivityThread.main(ActivityThread.java:4424) 06-29 10:29:02.777: E/AndroidRuntime(29516): at java.lang.reflect.Method.invokeNative(Native Method) 06-29 10:29:02.777: E/AndroidRuntime(29516): at java.lang.reflect.Method.invoke(Method.java:511) 06-29 10:29:02.777: E/AndroidRuntime(29516): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 06-29 10:29:02.777: E/AndroidRuntime(29516): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 06-29 10:29:02.777: E/AndroidRuntime(29516): at dalvik.system.NativeStart.main(Native Method) Code for iChecked (where the id is called) <ImageView android:id="@+id/checkBox" android:padding="2dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@android:drawable/checkbox_on_background"/>

    Read the article

  • TextView would not horizontally center

    - by theGreenCabbage
    My layout is the following: <TextView android:id="@+id/display_city" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/pollenType" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_below="@+id/get_pollen_index" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:layout_marginTop="51dp" android:textSize="40sp" /> As you can tell, Philadelphia, PA is left-aligned. No matter what I change, whether it's centering horizontal and vertical to true, it stays left-aligned. I have tried changing the layout via the XML and graphical user interface. In the graphical user interface, it indeed is "centered", but it remains non-centered. My layout positions are consistent across all my textviews, so I am unsure as to why this particular TextView is not centered.

    Read the article

  • How to update a TextView on ButtonClick with Spinner(s) values

    - by source.rar
    Hi, I am trying to populate a TextView based on the current selected options in 3 Spinner(s) but cant seem to figure out how to retrieve the selected values from the Spinners to invoke the update function with. Here is my current code (quite messy but I'm just learning Java :)), public class AgeFun extends Activity { private String[] dayNames; private String[] yearArray; private final static int START_YEAR = 1990; private static TextView textDisp; private Button calcButton; private static Spinner spinnerDay, spinnerYear, spinnerMonth; private static ArrayAdapter<?> monthAdapter, dayAdapter, yearAdapter; private int year, month, day; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); year = 2000; month = 1; day = 1; textDisp = (TextView) findViewById(R.id.textView1); calcButton = (Button) findViewById(R.id.button); calcButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Perform action on clicks AgeFun.updateAge(year, month, day); } }); // Month spinner spinnerMonth = (Spinner) findViewById(R.id.spinnerFirst); monthAdapter = ArrayAdapter.createFromResource( this, R.array.monthList, android.R.layout.simple_spinner_item); monthAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerMonth.setAdapter(monthAdapter); // Day spinner dayNames = new String[31]; for(int i =1; i <= 31; ++i) { dayNames[i-1] = Integer.toString(i); } spinnerDay = (Spinner) findViewById(R.id.spinnerSecond); dayAdapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item, dayNames); spinnerDay.setAdapter(dayAdapter); // Year spinner yearArray = new String[40]; for(int i =0; i < 40; ++i) { yearArray[i] = Integer.toString(START_YEAR+i); } spinnerYear = (Spinner) findViewById(R.id.spinnerThird); yearAdapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item, yearArray); spinnerYear.setAdapter(yearAdapter); updateAge(2000,1,1); } private static void updateAge(int year, int month, int day) { Date dob = new GregorianCalendar(year, month, day).getTime(); Date currDate = new Date(); long age = (currDate.getTime() - dob.getTime()) / (1000 * 60 * 60 * 24) / 365; textDisp.setText("Your are " + Long.toString(age) + " years old"); } } Any help with this would be great. TIA

    Read the article

  • null pointer exception in textview of setcontent

    - by kitokid
    I am getting the java.lang.NullPointerException on createTabContent for the following code. There are two tabspecs. When I called and set the tab , changed the tabs for the first time it is ok. But when i called again while I am on the second tab, its hit the null pointer exception for line : NoStudentText.setVisibility(View.VISIBLE); I will show No Student Text if there is no data for the student list. It shows the text for the first time call. But If I do second time call to that tab, got the error. tspecStudent.setContent(new TabContentFactory() { public View createTabContent(String arg0) { if(listStudent != null && listStudent .size() > 0) { //show the student list } else { TextView noStudentText = (TextView)findViewById(R.id.NoStudentText); noStudentText.setVisibility(View.VISIBLE); return noStudentText; } } });

    Read the article

  • Layout does not show up after Activity launch

    - by Peter
    I have an activity which invokes an onItemClick and launches another activity. This activity has a static layout(for testing purposes), but only thing I see is black(I even set the text color to white to check it out). My listener list.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) { //create new intent Intent item = new Intent(getApplicationContext(), Item.class); // Close all views before launching logged //item.putExtra("name", ((TextView)arg1).getText()); //item.putExtra("uid", user_id); item.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(item); // Close Login Screen onPause(); } }); My activity is here(not much to do it just launches the layout) public class Item extends Activity{ protected SQLiteDatabase myDB=null; protected String name; protected int uid; TextView yeart,year,itemname,comment,commentt,value,valuet,curr,currt; protected void onStart(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.herp); /*name=getIntent().getStringExtra("name"); uid=Integer.parseInt(getIntent().getStringExtra("uid")); itemname=(TextView) findViewById(R.id.itemName);//itemname.setText(name); year=(TextView) findViewById(R.id.itemYear); yeart=(TextView) findViewById(R.id.year); comment=(TextView) findViewById(R.id.itemComments); commentt=(TextView) findViewById(R.id.comments); curr=(TextView) findViewById(R.id.itemcurrent); currt=(TextView) findViewById(R.id.current); value=(TextView) findViewById(R.id.itemValue); valuet=(TextView) findViewById(R.id.value);*/ Database openHelper = new Database(this); myDB = openHelper.getReadableDatabase(); myDB=SQLiteDatabase.openDatabase("data/data/com.example.login2/databases/aeglea", null, SQLiteDatabase.OPEN_READONLY); }} And finally my XML layout <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/itemName" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="asdasd" android:gravity="center" android:layout_marginBottom="10px" android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="#fff" /> <TextView android:id="@+id/current" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Current" android:textSize="20dp" android:textStyle="bold" /> <TextView android:id="@+id/itemcurrent" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="asdasd" /> <TextView android:id="@+id/year" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Year" android:textSize="20dp" android:textStyle="bold" /> <TextView android:id="@+id/itemYear" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="asdasd" /> <TextView android:id="@+id/value" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Value" android:textSize="20dp" android:textStyle="bold" /> <TextView android:id="@+id/itemValue" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="TextView" /> <TextView android:id="@+id/comments" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Comments" android:textSize="20dp" android:textStyle="bold" /> <TextView android:id="@+id/itemComments" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="TextView" /> </LinearLayout>

    Read the article

  • How to add Editext and Button to Efficent Adapter which has a Icon and text

    - by jayanthgande
    Hi, I want to create a layout in such a way that on top edittext and button should be there in one row. The search text I enter in editext and click on search button. Then I want to display a custom list view where each row contains image and text.(As per the API demos example list14 I have tried). But when I run the application, button and edittext are being added to each row (i.e., Each row contains a image, text, editext, button. Can Any one guide how to resolve this issue. Below is my xml file: <!-- <FrameLayout android:layout_width="wrap_content" android:layout_height="0dip" android:layout_weight="1"></FrameLayout> --> <ImageView android:id="@+id/icon" android:layout_width="48dip" android:layout_height="48dip" /> <TextView android:id="@+id/text" android:layout_gravity="center_vertical" android:layout_width="0dip" android:layout_weight="1.0" android:layout_height="wrap_content" /> <!-- <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/prdsearchtb" android:text="@string/tb_prd_search_lbl"></EditText> --> <!-- <TableLayout android:id="@+id/TableLayout01" android:layout_width="fill_parent" android:layout_height="wrap_content"> <TableRow> --> <Button android:id="@+id/prdsrcbutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/btn_lbl_prd_search" android:layout_x="2px" android:layout_y="410px"></Button> <!-- </TableRow> </TableLayout> -- and Java File: /** * */ package org.techdata.activity; import android.app.AlertDialog; import android.app.ListActivity; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; /** * @author jayanthg * */ public class ProductSearch extends ListActivity { private static class ProductSearchAdapter extends BaseAdapter { private LayoutInflater mInflater; private Bitmap mIcon1; private Bitmap mIcon2; public ProductSearchAdapter(Context context) { mInflater = LayoutInflater.from(context); // Icons bound to the rows. mIcon1 = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon48x48_1); mIcon2 = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon48x48_2); } @Override public int getCount() { return DATA.length; } @Override public Object getItem(int position) { return position; } @Override public long getItemId(int position) { return position; } @Override public View getView(final int position, View convertView, ViewGroup parent) { ViewHolder holder; Button btn=null; if (convertView == null) { convertView = mInflater.inflate(R.layout.productsearch, null); // Creates a ViewHolder and store references to the two children // views // we want to bind data to. holder = new ViewHolder(); holder.text = (TextView) convertView.findViewById(R.id.text); holder.icon = (ImageView) convertView.findViewById(R.id.icon); btn=(Button)convertView.findViewById(R.id.prdsrcbutton); convertView.setTag(holder); } else { // Get the ViewHolder back to get fast access to the TextView // and the ImageView. holder = (ViewHolder) convertView.getTag(); } // Bind the data efficiently with the holder. holder.text.setText(DATA[position]); holder.icon.setImageBitmap((position & 1) == 1 ? mIcon1 : mIcon2); holder.icon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("image", " u clicked on icon Position" + position); } }); holder.text.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("Text", " u clicked on text Position" + position); } }); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("Button","U clicked on button"); } }); return convertView; } static class ViewHolder { TextView text; ImageView icon; } private static final String[] DATA = { "Abbaye de Belloc", "Abbaye du Mont des Cats" }; } ListView product_search_list; Button srch_btn; EditText srch_text; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new ProductSearchAdapter(this)); // setContentView(R.layout.productsearch); // getListView().setEmptyView(findViewById(R.id.text)); // srch_text = (EditText)findViewById(R.id.prdsearchtb); // srch_btn = (Button) findViewById(R.id.prdsearchtb); // srch_btn.setOnClickListener(new View.OnClickListener() { // // @Override // public void onClick(View v) { // callProductSearchAdapter(); // // } // }); } void callProductSearchAdapter() { setListAdapter(new ProductSearchAdapter(this)); } private void createDialog(String title, String text, final Intent i) { if (i == null) { AlertDialog ad = new AlertDialog.Builder(this).setIcon( R.drawable.alert_dialog_icon).setPositiveButton("Ok", null) .setTitle(title).setMessage(text).create(); ad.show(); } } } Regards: Jayanth

    Read the article

  • Android XML Parser isnt working

    - by Bram
    I am writing an android application with a XML parser. I have a parser that used to work but when I run it it isnt doing anything. This is my class: import java.net.URL; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; import android.app.Activity; import android.os.Bundle; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; public class XMLParsingUsingDomeActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout layout = new LinearLayout(this); layout.setOrientation(1); TextView ID[]; TextView vraag[]; TextView category[]; TextView a1[]; TextView p1[]; TextView a2[]; TextView p2[]; TextView a3[]; TextView p3[]; try { URL url = new URL( "http://128.140.217.126/vragen.xml"); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder dbu= dbf.newDocumentBuilder(); Document doc = dbu.parse(new InputSource(url.openStream())); doc.getDocumentElement().normalize(); NodeList nodeList = doc.getElementsByTagName("item"); ID = new TextView[nodeList.getLength()]; vraag = new TextView[nodeList.getLength()]; category = new TextView[nodeList.getLength()]; a1 = new TextView[nodeList.getLength()]; p1 = new TextView[nodeList.getLength()]; a2 = new TextView[nodeList.getLength()]; p2 = new TextView[nodeList.getLength()]; a3 = new TextView[nodeList.getLength()]; p3 = new TextView[nodeList.getLength()]; for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); ID[i] = new TextView(this); vraag[i] = new TextView(this); category[i] = new TextView(this); a1[i] = new TextView(this); p1[i] = new TextView(this); a2[i] = new TextView(this); p2[i] = new TextView(this); a3[i] = new TextView(this); p3[i] = new TextView(this); Element fstElmnt = (Element) node; NodeList nameList = fstElmnt.getElementsByTagName("ID"); Element nameElement = (Element) nameList.item(0); nameList = nameElement.getChildNodes(); ID[i].setText(((Node) nameList.item(0)).getNodeValue()); NodeList vraagList = fstElmnt.getElementsByTagName("vraag"); Element vraagElement = (Element) vraagList.item(0); vraagList = vraagElement.getChildNodes(); vraag[i].setText(((Node) vraagList.item(0)).getNodeValue()); NodeList a1List = fstElmnt.getElementsByTagName("a1"); Element a1Element = (Element) a1List.item(0); a1List = a1Element.getChildNodes(); a1[i].setText(((Node) a1List.item(0)).getNodeValue()); NodeList p1List = fstElmnt.getElementsByTagName("p1"); Element p1Element = (Element) p1List.item(0); p1List = p1Element.getChildNodes(); p1[i].setText(((Node) p1List.item(0)).getNodeValue()); NodeList a2List = fstElmnt.getElementsByTagName("a2"); Element a2Element = (Element) a2List.item(0); a2List = a2Element.getChildNodes(); a2[i].setText(((Node) a2List.item(0)).getNodeValue()); NodeList p2List = fstElmnt.getElementsByTagName("p2"); Element p2Element = (Element) p2List.item(0); p2List = p2Element.getChildNodes(); p2[i].setText(((Node) p2List.item(0)).getNodeValue()); NodeList a3List = fstElmnt.getElementsByTagName("a3"); Element a3Element = (Element) a3List.item(0); a3List = a3Element.getChildNodes(); a3[i].setText(((Node) a3List.item(0)).getNodeValue()); NodeList p3List = fstElmnt.getElementsByTagName("p3"); Element p3Element = (Element) p3List.item(0); p3List = p3Element.getChildNodes(); p3[i].setText(((Node) p3List.item(0)).getNodeValue()); layout.addView(category[i]); Toast.makeText(this, "ID: " + i + "\n" + "Vraag: " + ((Node) vraagList.item(0)).getNodeValue() + "\n" + "A1: " + ((Node) a1List.item(0)).getNodeValue() + "\n" + "P2: " + ((Node) p1List.item(0)).getNodeValue() + "\n" + "A2: " + ((Node) a2List.item(0)).getNodeValue() + "\n" + "P2: " + ((Node) p2List.item(0)).getNodeValue() + "\n" + "A3: " + ((Node) a3List.item(0)).getNodeValue() + "\n" + "P3: " + ((Node) p3List.item(0)).getNodeValue(), Toast.LENGTH_LONG).show(); } } catch (Exception e) { System.out.println("XML Pasing Excpetion = " + e); } /** Set the layout view to display */ setContentView(layout); } } And my manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="your.pace.namace" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="10" /> <uses-permission android:name="android.permission.INTERNET"></uses-permission> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".XMLParsingUsingDomeActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> And the logcat output is worthless. I didnt change the code but its just not working anymore.

    Read the article

  • Creating Linear Layout with TextViews using a for loop

    - by cad8
    Hi all, I was wondering if there is a way to dynamically create an additional linear layout with a textview within a predefined liner layout. THis is my code so you get the gist of what I am asking: LinearLayout MainLL= (LinearLayout) findViewById(R.id.myLayoutId); for(int i=0; i<5; i++) { LinearLayout childLL= new LinearLayout(this); childLL.setOrientation(LinearLayout.VERTICAL); childLL.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); childLL.setGravity(Gravity.LEFT); TextView text = new TextView(this); text.setText("The Value of i is :"i); text.setTextSize(12); text.setGravity(Gravity.LEFT); text.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); childLL.addView(text); MainLL.addView(childLL); } My problem is that I am only getting "The Value of i is :0" as the output, i.e. the first instance. Any help would be much appreciated

    Read the article

  • Android ViewPager Displaying TextView in Layout

    - by Ammonious
    I'm having a problem getting my viewpager to work correctly. Currently the bottom part of my layout will page across but the remaining part will not Here's my code that I have in my PageAdapter public class MyPageAdapter extends PagerAdapter { public int getCount() { return 31; } public Object instantiateItem(View collection, int position) { LayoutInflater inflater = (LayoutInflater) collection.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); int resId = 0; switch (position) { case 0: resId = R.layout.main_menu; break; case 1: resId = R.layout.article1; break; case 2: resId = R.layout.article2; break; .... .... View view = inflater.inflate(resId, null); ((ViewPager) collection).addView(view, 0); return view; This is what I have for my XML <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@drawable/background" android:clickable="true" android:id="@+id/layout13" android:weightSum="0"> <TextView android:id="@+id/textView01" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical|center_horizontal" android:padding="12dp" android:text="@string/article13" android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="#000000" /> <TextView android:id="@+id/textView02" android:layout_width="match_parent" android:layout_height="302dp" android:gravity="center_vertical|center_horizontal" android:text="@string/body13" android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="#000000" /> <android.support.v4.view.ViewPager android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@id/viewPager" > </android.support.v4.view.ViewPager> </LinearLayout> I've tried Moving the around in my XML layout to right underneath my LinearLayout and i get the full screen but all my text disappears. It's probably something simple i'm missing but any help on this would be greatly appreciated!

    Read the article

  • Android 2.1 fling gesture captured on textview but still a contextmenu opens

    - by hermo
    The following problem seems unique to 2.1, happens both on an emulator and on a nexus. The same example works fine on other platforms I've tested (1.5, 1.6 and 2.0 emulators). I've added created gestureListener as described in this post. The difference is that I've added the listener on a TextView which also has a contextMenu registered, i.e. sth like the following: onCreate(...) { ... // Layout contains a large TextView on which I want to add a context menu tv = findViewById(R.id.text_view); tv.registerForContextMenu(this); // create the gestureListener according above mentioned post. gestureListener = ... // set the listener on the text-view tv.setOnTouchListener(gestureListener); ... } When testing it, the correct gesture is recognized alright, but every other time it also causes the context menu to be opened. As the same example is working on non 2.1 platforms, I've got a feeling it is not my code that is the problem... Thankful for any suggestions.

    Read the article

  • reset TextView scroll to top

    - by JayAvon
    Okay well I apologize for how sloppy this code is, but I still cant figure out how to post a code tag on here correctly. So I am making an Android application (Java) and i have a scrolling text field. If the user scrolls a long row down and stays at the end when they click the next row and if it is short, it will be scrolled down on that element too even though it may be a 1 line(and non scrollable) row. I was wondering if there is any way I can call something to right after txtLvlInfo.setText to reset the x-scroll value to 0 or something so it is always reset to the top of the content, long or short. Thanks for any help with this and please let me know if I need to clarify more. TextView txtLvlInfo = (TextView) findViewById(R.id.txtLevelInfo); txtLvlInfo.setMovementMethod(new ScrollingMovementMethod()); switch (v.getId()){ case R.id.row1: txtLvlInfo.setText("1: My text view is only two lines max and so I set it to scroll, if the user clicks row2 to load that text while having me scrolled down they have to click and pull to drag back down to the top of text view 2 row."); break; case R.id.row2: txtLvlInfo.setText("I only fill line 1 of the two."); break; android:textColor="#052027" android:text="" android:id="@+id/txtLevelInfo" android:scrollbars="vertical" android:layout_alignParentLeft="true" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_toRightOf="@+id/minimizeBtn" android:layout_marginRight="38dip"

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >