android-json-form-wizard icon indicating copy to clipboard operation
android-json-form-wizard copied to clipboard

how to set orination horizontal dynamic

Open shashipyadav opened this issue 5 years ago • 9 comments

shashipyadav avatar Jun 08 '19 09:06 shashipyadav

what component you want to change the orientation

Durgnan avatar Jun 08 '19 10:06 Durgnan

placed two button in horizontal

shashipyadav avatar Jun 08 '19 13:06 shashipyadav

If you are using linear layout then place this attribute in the layout declaration orientation="orient" Orient will be either horizontal or vertical

Durgnan avatar Jun 08 '19 15:06 Durgnan

Hope this helps

Durgnan avatar Jun 08 '19 15:06 Durgnan

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

shashipyadav avatar Jun 10 '19 04:06 shashipyadav

//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 } });

Durgnan avatar Jun 10 '19 20:06 Durgnan

i have list button every button action are different how can perform this action

shashipyadav avatar Jun 11 '19 05:06 shashipyadav

Then you have to make a custom list adapter

Durgnan avatar Jun 11 '19 11:06 Durgnan

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)

shashipyadav avatar Jun 11 '19 13:06 shashipyadav