How to place focus in child view of list row?

by Oleksiy Kokachev » Fri, 13 Mar 2009 01:42:35 GMT


Sponsored Links
 Hi..
I have ListView, where each row contains two edittext boxes. I'd like
on list item selected(using Dpad) place focus on first edittext box. I
tried the following code, but it does not work:
ListView list = (ListView) findViewById(R.id.list);
OnItemClickListener click_listener = new OnItemClickListener() {
                public void onItemClick(AdapterView<?> parent, View view, int
position, long id){
                        EditText box1 = (EditText)view.findViewById(R.id.box1);
                        box1.requestFocus();
                    return ;
                }

        };
        list.setOnItemClickListener(click_listener);
}

Any help is appreciated.

Thanks in advance.

--~--~---------~--~----~------------~-------~--~----~



How to place focus in child view of list row?

by Oleksiy Kokachev » Fri, 13 Mar 2009 01:42:56 GMT


 Hi..
I have ListView, where each row contains two edittext boxes. I'd like
on list item selected(using Dpad) place focus on first edittext box. I
tried the following code, but it does not work:
ListView list = (ListView) findViewById(R.id.list);
OnItemClickListener click_listener = new OnItemClickListener() {
                public void onItemClick(AdapterView<?> parent, View view, int
position, long id){
                        EditText box1 = (EditText)view.findViewById(R.id.box1);
                        box1.requestFocus();
                    return ;
                }

        };
        list.setOnItemClickListener(click_listener);
}

Any help is appreciated.

Thanks in advance.

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Help with tabbed view

Sorry if this is a resend...been having issues emailing to the group.
------

I'm new to Android development so please bear with me.  I have created
an app in WebOS and I'm keen to try and re-create for the Android
platform.  I have tried to follow the tutorial for creating a tabbed
view and to some extent I have succeeded.  However, the problem that I
am having is that when I switch from tab to tab any text or graphics
is overwritting the tab elements and not displaying below the tabs
themselves.  I'm sure I've done something stupid that is easy to fix.

Here are the files that I have.  I have my main class which extends
TabActivity.  The code is as follows:

*package com.dtwconsulting.golfcaddie;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.widget.TabHost;

public class GolfCaddie extends TabActivity {
   /** Called when the activity is first created. */
   @Override

   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(*
*savedInstanceState);
       setContentView(R.layout.**splashmain);

* *       Resources res = getResources(); // Resource object to get
Drawables
       TabHost tabHost = getTabHost();  // The activity TabHost
       TabHost.TabSpec spec;  // Resusable TabSpec for each tab
       Intent intent;  // Reusable Intent for each tab

* *       // Create an Intent to launch an Activity for the tab (to be
reused)
       intent = new Intent().setClass(this, MainActivity.class);

* *       // Initialize a TabSpec for each tab and add it to the TabHost
       spec = tabHost.newTabSpec("main").**setIndicator("Main",
                         res.getDrawable(R.drawable.ic_**tab_main))
                     .setContent(intent);
       tabHost.addTab(spec);

* *       // Do the same for the other tabs
       intent = new Intent().setClass(this, PlayersActivity.class);
       spec = tabHost.newTabSpec("players").**setIndicator("Players",
                         res.getDrawable(R.drawable.ic_**tab_players))
                     .setContent(intent);
       tabHost.addTab(spec);

* *       intent = new Intent().setClass(this, CoursesActivity.class);
       spec = tabHost.newTabSpec("courses").**setIndicator("Courses",
                         res.getDrawable(R.drawable.ic_**tab_courses))
                     .setContent(intent);
       tabHost.addTab(spec);

* *       tabHost.setCurrentTab(0);

* *   }

* *   public boolean onCreateOptionsMenu(Menu menu) {
       MenuInflater inflater = getMenuInflater();
       inflater.inflate(R.menu.main_**menu, menu);
       return true;
   }
}*

My R.layout.splashmain XML code is as follows:

*<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android 
<http://schemas.android.com/apk/res/android>"

   android:id="@android:id/**tabhost"
   android:layout_width="fill_**parent"
   android:layout_height="fill_**parent">
<TabWidget  android:id="@android:id/tabs"
                       android:layout_width="fill_**parent"
                       android:layout_height="fill_**parent" />
<FrameLayout android:id="@android:id/**tabcontent"
                        android:layout_width="fill_**parent"
                        android:layout_height="fill_**parent"
                        android:padding="5dp" />
</TabHost>*

In addition to the above I have a class file for each tab and a layout
file for each tab too.  To give an example of the main class and XML
layout file:

*package com.dtwconsulting.golfcaddie;

import android.app.Activity;* *
import android.os.Bundle;

public class MainActivity extends Activity {* *
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(**savedInstanceState);

* *       setContentView(R.layout.main);
   }
}

<?xml version="1.0" encoding="utf-8"?>* *
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/ 
<http://schemas.android.com/apk/res/>

android"
                             android:layout_width="wrap_**content"
                             android:layout_height="fill_**parent"
                             android:fitsSystemWindows="**true"
                             android:background="@drawable/**golfcaddie">
</LinearLayout>*

So, when this main tab is displayed the background image
(golfcaddie.png) completely displays on the entire screen over the top
of the tabs.  I've tried playing around with things but all to no
avail.  I either get the background overlaying the tabs, or I get
nothing at all.  I suspect that I am just not grasping these layouts
and how they interact.

Any help/direction on this would be much appreciated, and perhaps I am
not even doing this the best way.  I ended up Googling about doing a
tabbed view and was lead a little away from the Google docs.

--
------------------------------------------------------------------------

David Williams
Check out our WebOS mobile phone app for the Palm Pre and Pixi:
<http://www.dtw-consulting.com/GolfCaddie> Golf Caddie 
<http://www.dtw-consulting.com/GolfCaddie> | Golf Caddie Forum 
<http://www.dtw-consulting.com/GolfCaddie/forum> | Golf Caddie FAQ 
<http://www.dtw-consulting.com/GolfCaddie/faq.html> by DTW-Consulting, Inc.



--

<<inline: GClogo.png>>

2. Programatically change the color of layout

Hello All,
I am trying to programatically change the layout color but of a
relative layout (tried Linear layout but didn't change), but cannot
change it.

Also trying to debug the app doesn't help, there was not message
related to my TAG.

the application stood still after layout was colored initially.

"rellay" is id of Relative Layout.

package com.test.intentdemo;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
//import android.os.SystemClock;
import android.widget.RelativeLayout;
import android.util.*;
import java.lang.Thread;

public class intentDemo extends Activity {
    /** Called when the activity is first created. */
    RelativeLayout lLayout;
    public static final String TAG="MyActivity";
        @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        lLayout = (RelativeLayout) findViewById(R.id.rellay);
        if (Log.isLoggable(TAG,0))
        {
                Log.e(TAG,"ERROR BEFORE");
                Log.i(TAG,"INFO BEFORE");
                Log.d(TAG,"DEBUG BEFORE");

                        lLayout.setBackgroundColor(Color.parseColor("#000000"));
                        //SystemClock.sleep(2000);
                        try
                                {
                                Thread.currentThread();
                                Thread.sleep(2000);
                                }
                                catch (Exception e)
                                {
                                //e.message();
                                }


                Log.e(TAG,"ERROR AFTER");
                Log.i(TAG,"INFO AFTER");
                Log.d(TAG,"DEBUG AFTER");
        }
    }
}

Any help regarding this would be helpful.

Thanks,
Sid

-- 

3. updating problem in eclipse

4. how to correct market issue

5. AudioFlinger DirectThread

6. Unable to open connection to supplicant on "/data/system/wpa_supplicant/wlan0"

7. compiling libdvm on ubuntu