### FormOptions.setReadonly Example Source: https://github.com/google/libaddressinput/blob/master/_autodocs/java-enums.md Example of using setReadonly. ```java FormOptions options = new FormOptions() .setReadonly(AddressField.COUNTRY); // Country already determined ``` -------------------------------- ### Complete MainActivity Example Source: https://github.com/google/libaddressinput/blob/master/android/README.md A full example of MainActivity integrating the AddressWidget. ```java package com.example.google.widgetdemo; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.ViewGroup; import com.android.i18n.addressinput.AddressWidget; import com.google.i18n.addressinput.common.FormOptions; import com.google.i18n.addressinput.common.ClientCacheManager; import com.google.i18n.addressinput.common.SimpleClientCacheManager; public class MainActivity extends AppCompatActivity { private AddressWidget addressWidget; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ViewGroup viewGroup = (ViewGroup) findViewById(R.id.addresswidget); FormOptions defaultFormOptions = new FormOptions(); ClientCacheManager cacheManager = new SimpleClientCacheManager(); this.addressWidget = new AddressWidget(this, viewGroup, defaultFormOptions, cacheManager); } } ``` -------------------------------- ### AddressProblemType Example Source: https://github.com/google/libaddressinput/blob/master/_autodocs/java-enums.md Example of using AddressProblemType. ```java AddressProblemType problem = AddressProblemType.MISSING_REQUIRED_FIELD; String id = problem.keyname(); // "missing_required_field" ``` -------------------------------- ### Using Custom Storage Example Source: https://github.com/google/libaddressinput/blob/master/_autodocs/cpp-data-sources.md Example of how to use a custom storage implementation with PreloadSupplier and AddressValidator. ```cpp #include #include int main() { // Create custom storage auto storage = new FileStorage("/tmp/address_cache"); // Create source (implementation dependent) auto source = new SomeSource(); // Create supplier with custom storage auto supplier = std::unique_ptr( new i18n::addressinput::PreloadSupplier(source, storage) ); // Create validator auto validator = std::make_unique( supplier.get() ); // Use validator // ... return 0; } ```