Add CustomView to ToolBar [make search bar]



Hi guys in this article I will show you how to add CustomView to your ToolBar in Sketchware 

What you need is:
  1. Enabling appcompat library 


  2. Create a new CustomView 


  3. Design your CustomView for me I added edittext1 & button1


  4. Add this code

getSupportActionBar().setDisplayShowTitleEnabled(false);

getSupportActionBar().setDisplayHomeAsUpEnabled(false);

View logo = getLayoutInflater().inflate(R.layout.dvv, null);


logo.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.MATCH_PARENT));
_toolbar.addView(logo);
final Button button1 = (Button)logo.findViewById(R.id.button1);
final EditText edittext1 = (EditText)logo.findViewById(R.id.edittext1);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
SketchwareUtil.showMessage(getApplicationContext(), edittext1.getText().toString());
}
});


Follow this video to understand more 

Comments

Post a Comment

Popular posts from this blog

Read Json file from asset in Sketchware Pro

Change wallpaper Programmatically Sketchware

Web Scraping With Jsoup in Sketchware