
Arreglo de EditText
Publicado por Emilio (10 intervenciones) el 20/10/2017 20:27:22
Hola que tal?
tengo un problema y no se como resolverlo
en mi proyecto necesitan poner un botón que valla creando EditText hasta ahí no tengo problema pero de hay otro botón va a capturar los datos de todos los EditText es donde tengo problemas como capturo todos los datos de los EdtiText y los pongo en un ArrayList o List o String[] porfavor necesito su ayuda
el .xml es un fragmento
tengo un problema y no se como resolverlo
en mi proyecto necesitan poner un botón que valla creando EditText hasta ahí no tengo problema pero de hay otro botón va a capturar los datos de todos los EditText es donde tengo problemas como capturo todos los datos de los EdtiText y los pongo en un ArrayList o List o String[] porfavor necesito su ayuda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.fapv2.proto.fapv2.R;
public class RegistroMultiple extends Fragment{
Button BTNA,BTNC;
LinearLayout LLH;
EditText TXTP;
int CCIP;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_psicofisico_registrarmultiple, container, false);
LLH=(LinearLayout) rootView.findViewById(R.id.LLH);
BTNA=(Button) rootView.findViewById(R.id.BTNAC);
BTNC=(Button) rootView.findViewById(R.id.BTNEV);
TXTP=(EditText) rootView.findViewById(R.id.T0);
CCIP=0;//Reinicia el contador a 0 cuando entra al fragmento
BTNA.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CCIP=CCIP+1;
TextView lblcip=new TextView(getContext());
EditText txtnu=new EditText(getContext());
LinearLayout lin=new LinearLayout(getContext());
//lblcip.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
lblcip.setWidth(100);
lblcip.setText("CIP");
lblcip.setTextSize(18);
//txtnu.setGravity(Gravity.CENTER_VERTICAL);
txtnu.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
txtnu.setWidth(250);
txtnu.setId(CCIP);
txtnu.setText("hola"+CCIP);
lin.addView(lblcip);
lin.addView(txtnu);
LLH.addView(lin);
}
});
BTNC.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TXTP.getText();
for (int i=0;i<CCIP;i++){
//Aca es donde debe capturar los datos de los EditText
}
}
});
return rootView;
}
}
el .xml es un fragmento
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.fapv2.proto.fapv2.PuntajePsicofisico$PlaceholderFragment">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/LLH"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:id="@+id/BTNAC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Agregar" />
<Button
android:id="@+id/BTNEV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Evaluar" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="CIP"
android:textSize="18sp" />
<EditText
android:id="@+id/T0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textPersonName" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
- Cap.rar(26,5 KB)
Valora esta pregunta


0