我需要以编程方式更改Contextual Action Bar颜色。怎么做我知道的风格。提前谢谢
答案 0 :(得分:-1)
使用代码
class LocalizacaoForm(forms.ModelForm):
# The rest of the form ...
# ...
def save(self, commit=False):
localizacao = super(LocalizacaoForm, self).save(commit=False)
# create an instance of Coordenada
coordenada = Coordenada.objects.create(
latitude=self.cleaned_data['latitude'],
longitude=self.cleaned_data['longitude'],
altitude=self.cleaned_data['altitude'],
erro_horizontal=self.cleaned_data['erro_horizontal']
)
# create an instance of Endereco
endereco = Endereco.objects.create(
cep=self.cleaned_data['cep'],
uf=self.cleaned_data['uf'],
localidade=self.cleaned_data['localidade'],
)
# add those instances to localizacao
localizacao.coordenada_geografica = coordenada
localizacao.endereco = endereco
if commit:
localizacao.save()
return localizacao
如果您使用的是支持库,请尝试使用
getActionBar().setBackgroundDrawable( <create a background drawable with solid rectangle and color as what you want>);