Essa aqui é minha classe layout, onde crio layout que será listado pelo adapter.
public class PropriedadeCustomAdapterView extends LinearLayout {
private static final String TAG = "PropriedadeCustomAdapterView";
public PropriedadeCustomAdapterView(Context context, Propriedade propriedade) {
super(context);
setId(propriedade.propriedade_ID);
setOrientation(LinearLayout.HORIZONTAL);
setPadding(0, 6, 0, 6);
//Adicionando TextView, descricao da Propriedade
LinearLayout.LayoutParams Params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
Params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
LinearLayout PainelI = new LinearLayout(context);
PainelI.setOrientation(LinearLayout.VERTICAL);
// PainelI.setGravity(Gravity.LEFT);
TextView textName = new TextView( context );
textName.setTextSize(16);
textName.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
textName.setText( propriedade.nome);
PainelI.addView(textName);
// TextView textName2 = new TextView( context );
// textName2.setTextSize(16);
// textName2.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
// textName2.setText("sdasasa");
// PainelI.addView(textName2);
//
EditText edtText = new EditText(context);
// edtText.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
edtText.setLayoutParams(new GridView.LayoutParams(200, 53));
edtText.requestFocusFromTouch();
edtText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
Log.e(TAG, "durante - "+s);
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
Log.w(TAG, "before - "+s);
}
@Override
public void afterTextChanged(Editable s) {
Log.i(TAG, "after - "+s);
}
});
PainelI.addView(edtText);
addView(PainelI, Params);
}
}
public View getView(final int position, View convertView, ViewGroup parent)
{
Propriedade propriedade = lstPropriedade.get(position);
View v = new PropriedadeCustomAdapterView(this.context, propriedade );
v.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Toast.makeText(context, position, Toast.LENGTH_SHORT).show();
}
});
return v;
}
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
DBAdapter db = new DBAdapter(getActivity());
db.open();
lstPropriedade = PropriedadeAdapter.listaPropriedades();
db.close();
if (getActivity() != null) {
ListAdapter listAdapter = new CustomAdapter(getActivity(),
lstPropriedade);
lv1.setAdapter(listAdapter);
}
}
Lembrando não há xml crio tudo no primeiro código
abs
.
Em segunda-feira, 17 de dezembro de 2012 16h01min04s UTC-2, luiszacheu escreveu:
-- Em segunda-feira, 17 de dezembro de 2012 16h01min04s UTC-2, luiszacheu escreveu:
Estou fazendo um ItemAdapter customizado para uma ListView, porem estou tendo os seguintes problemas:
- Meu item é composto por um TextView e um EditText quando deixo somente o TextView eu clico que faço mostrar um Toast, porem quando adiciono o EditText além de não conseguir clicar mais no item eu nao consigo escrever no EditText, pois o teclado virtual aparece mas nao aparece o cursor.
Alguém poria me dar uma ajuda.Obrigado!






0 comentários:
Postar um comentário