android-json-form-wizard
android-json-form-wizard copied to clipboard
how to set orination horizontal dynamic
what component you want to change the orientation
placed two button in horizontal
If you are using linear layout then place this attribute in the layout declaration orientation="orient" Orient will be either horizontal or vertical
Hope this helps
public class ButtonFactory implements FormWidgetFactory {
@Override
public List<View> getViewsFromJson(String stepName, Context context, JSONObject jsonObject, CommonListener listener) throws Exception {
LinearLayout ll = createAndPrepareFoldingContainer(context);
boolean value= (boolean) jsonObject.get("boolen");
List<View> views = new ArrayList<>(1);
if(value){
JSONArray options = jsonObject.getJSONArray(JsonFormConstants.OPTIONS_FIELD_NAME);
for (int i = 0; i < options.length(); i++) {
JSONObject item = options.getJSONObject(i);
Button uploadButton3 = new Button(context);
uploadButton3.setText(item.getString("uploadButtonText"));
ll.addView(uploadButton3);
}
views.add(ll);
}else {
Button uploadButton = new Button(context);
uploadButton.setText(jsonObject.getString("uploadButtonText"));
uploadButton.setLayoutParams(getLayoutParams(WRAP_CONTENT, WRAP_CONTENT, 0, 0, 0, (int) context
.getResources().getDimension(R.dimen.default_bottom_margin)));
views.add(uploadButton);
}
return views;
}
}
how to add setOnClickListener every button
//consider a button b1 and its declarations then //it's on click listener would be b1.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v) { //do something } });
i have list button every button action are different how can perform this action
Then you have to make a custom list adapter
no JSONArray options = jsonObject.getJSONArray(JsonFormConstants.OPTIONS_FIELD_NAME);
for (int i = 0; i < options.length(); i++) {
JSONObject item = options.getJSONObject(i);
Button uploadButton3 = new Button(context);
uploadButton3.setText(item.getString("uploadButtonText"));
ll.addView(uploadButton3);
}
views.add(ll)