In your adapter, you should be setting the other case in else condition as well. Example is below.
I saw you are using wrap_content for your width. So your LinearLayout will wrap your content and can't align to left or right of your layout. You should use fill parent for your LinearLayout in order it to align it's contents if there is sufficient space
if(splitted[1].equalsIgnoreCase("aeiou"))
{
chats=splitted[0];
Toast.makeText(context, "You entered...."+chats, Toast.LENGTH_SHORT).show();
LinearLayout my_layout = (LinearLayout) rowView.findViewById(R.id.main_layout);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.RIGHT;
my_layout.setLayoutParams(params);
//my_layout.setGravity(Gravity.RIGHT);
txtTitle.setText(chats);
}
}
else{
LinearLayout my_layout = (LinearLayout)rowView.findViewById(R.id.main_layout);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.LEFT;
my_layout.setLayoutParams(params);
txtTitle.setText(web.get(position));
}