How can i create Vertical arrangement?

i am trying to create a vertical arrangement but unable to create.
Hope anyone help me in Creating this extension.

My code

LinearLayout ll = new LinearLayout(context);
ll.setOrientation(LinearLayout.VERTICAL);
ll.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

My Imports

import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;

this code is not working for me .

sur @Mohamed_Tamer kindly have a look here

Note - please change my Topic category.

You need to add your linearLayout in a ViewGroup, you might use ViewGroup.add(view) method.

There isn’t a category for extension development in kodular community, you should ask in the app Inventor community:

2 Likes

please wait

the problem is that i am unable to create a Linear Layout

i already used this code

((ViewGroup) layout.getView()).addView(ll);

You didn’t show this code :slightly_smiling_face:

How? What happens when you use it.

1 Like

it gives me error called - illegal character

Show the log, which character the compiler points to.

1 Like

i don’t know does this can really solve my error.

take ______ = space

previous code

______LinearLayout ll = new LinearLayout(context);

new code

LinearLayout ll = new LinearLayout(context);

Just removed the Space and it works fine

this solve my error . thanks for your time @Mohamed_Tamer

Seems that you was having a special character there, that the compiler failed to resolve it, which got removed when you removed the space :thinking:

1 Like

sur @Mohamed_Tamer , i am creating a Base Adapter with this Created View which is ll Linear Layout.

i have store the ll layout in a Variable - llLayout

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class Adapter extends BaseAdapter {
	
	/**
	 * Constructr
	 * @param contex
	 */
	public Adapter(Context context) {
	}
	
	public int getCount() {
		// TODO Auto-generated method stub
		return 10;
	}

	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		View newView = convertView;
		if ( newView == null )
		{
			newView = MyClass.llLayout;
		}
		return newView;
	}

}

please check my code and let me know that this will work or not

please sur @Mohamed_Tamer check this