Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to set orination horizontal dynamic #44

Open
shashipyadav opened this issue Jun 8, 2019 · 9 comments
Open

how to set orination horizontal dynamic #44

shashipyadav opened this issue Jun 8, 2019 · 9 comments

Comments

@shashipyadav
Copy link

No description provided.

@shashipyadav shashipyadav changed the title how to set orination how to set orination horizontal dynamic Jun 8, 2019
@Durgnan
Copy link

Durgnan commented Jun 8, 2019

what component you want to change the orientation

@shashipyadav
Copy link
Author

placed two button in horizontal

@Durgnan
Copy link

Durgnan commented Jun 8, 2019

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

@Durgnan
Copy link

Durgnan commented Jun 8, 2019

Hope this helps

@shashipyadav
Copy link
Author

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

@Durgnan
Copy link

Durgnan commented Jun 10, 2019

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

@shashipyadav
Copy link
Author

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

@Durgnan
Copy link

Durgnan commented Jun 11, 2019

Then you have to make a custom list adapter

@shashipyadav
Copy link
Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants