Solve my bug in ListView

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Solve my bug in ListView

Postby arams » Mon May 18, 2009 12:33 pm

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

public class ClickableList extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new list1(this));
}
}

CView .JAVA
package com.rams;

import java.util.Vector;
import android.content.Context;
import android.view.View;

import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;


public class CView extends LinearLayout implements OnItemClickListener{

//private IconifiedTextView pview;
protected ListView lView;
protected String[] list={"aaaaa "," bbbbbbb","cccccc ","ddd","eeee","ffffff"};
protected Vector objList;
protected Context context;
protected ArrayAdapter adap;

public CView(Context context) {
super(context);
this.context=context;
setOrientation(VERTICAL);
lView=new ListView(context);
lView.setOnItemClickListener(this);
objList=new Vector();
this.addView(lView);

lView.setDividerHeight(12);
lView.setVerticalScrollBarEnabled(false);

}
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
//(//(Activity)context).setContentView(lView);
}

}

list1.JAVA

package com.rams;

import java.util.Enumeration;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.LinearLayout.LayoutParams;

public class list1 extends CView{
String[] aa={"111","2222","3333","444","555","666","777","888","999","1010","1111","1212"};
public list1(Context context) {

super(context);
this.context=context;
list=aa;
adap=new ArrayAdapter(context,android.R.layout.simple_list_item_1,list);
lView.setAdapter(adap);

}


public void onItemClick(AdapterView arg0, View v, int index, long arg3) {

((Activity)context).setContentView(new list2(context));
}
}


list2.JAVA

import java.util.Enumeration;
import java.util.Hashtable;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import android.widget.LinearLayout.LayoutParams;

public class list2 extends CView{
String[] aa={"aaa","bbb","ccc","ddd","eee","fff"};
public list2(Context context) {

super(context);
this.context=context;
list=aa;
adap=new ArrayAdapter(context,android.R.layout.simple_expandable_list_item_1,list);
lView.setAdapter(adap);

}


@Override
public void onItemClick(AdapterView arg0, View arg1, int index, long arg3) {

}

}






R.JAVA


public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
}
arams
Experienced Developer
Experienced Developer
 
Posts: 89
Joined: Fri May 08, 2009 7:45 am

Top

Postby arams » Mon May 18, 2009 12:38 pm

In this above code when i click the first list(....using keypad...) it will move to the next one....but i did not got the focus by pressing the down arrow .I got the focus when i touch the list.....Is there any mistake am made in my code?....

Tell ur view...
THANKS
arams
Experienced Developer
Experienced Developer
 
Posts: 89
Joined: Fri May 08, 2009 7:45 am

Postby arams » Mon May 18, 2009 12:55 pm

I got the focus by using keypad in first1....but dont get in after enter into next list
Attachments
Picture1.png
Picture1.png (122.8 KiB) Viewed 231 times
Picture2.png
Picture2.png (144.32 KiB) Viewed 231 times
arams
Experienced Developer
Experienced Developer
 
Posts: 89
Joined: Fri May 08, 2009 7:45 am

Postby arams » Tue May 19, 2009 12:24 pm

i got the output


after passing the content to listview....use the following method



requestFocus();
arams
Experienced Developer
Experienced Developer
 
Posts: 89
Joined: Fri May 08, 2009 7:45 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests