上一个问题:
我可以知道为什么当我尝试启动RecyclerView活动从片段进行搜索时会发生此错误。
添加适配器后:
错误:null对象引用上的OwnerDAO.getOwner()'
片段代码:
#include <stdio.h>
#include <stdbool.h>
bool prime(int);
int main()
{
int x;
scanf("%d",&x);
if (x < 2)
printf("its not prime\n");
else
{
if (prime(x))
printf("its prime\n");
else
printf("its not prime\n");
}
return 0;
}
bool prime(int x)
{
int i;
for (i = 2; i*i <= x; i++){
if (x%i == 0)
return false;
}
return true;
}
搜索适配器:
RecyclerView recyclerView;
RecyclerView.LayoutManager layoutManager;
SearchAdapter adapter;
OwnerDAO mOwnerDao;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.activity_search, container, false);
recyclerView = (RecyclerView)v.findViewById(R.id.recycler_search);
layoutManager = new LinearLayoutManager(this.getActivity());
mOwnerDao = new OwnerDAO(getContext())
adapter = new SearchAdapter(getContext(),mOwnerDao.getOwner());
recyclerView.setLayoutManager(layoutManager);
recyclerView.setHasFixedSize(true);
recyclerView.setAdapter( adapter );
return v;
}
答案 0 :(得分:1)
在import maya.cmds as mc
if mc.window("ram", exists =True):
mc.deleteUI(ram)
colors = {'Red':(1,0,0), 'Blue':(0,0,1), 'Green':(0,1,0)}
shader = 'lambert1'
ram = mc.window("Material and Texture",t = "Material and Texture v0.9", w=300, h=300)
mc.columnLayout(adj = True)
imagePath = mc.internalVar(upd = True)+"icons/scriptlogo.jpg"
mc.image(w=300,h=200,image = imagePath)
# A dropdown menu deisnged to change material/color of octopus (the colors below are used as a test)
menu = mc.optionMenu(label = "Material", cc=setColor)
mc.menuItem (label="Red")
mc.menuItem (label="Blue")
mc.menuItem (label="Yellow")
mc.menuItem (label="Green")
mc.menuItem (label="Orange")
mc.menuItem (label="Purple")
def setColor(*args):
colorName = mc.optionMenu(menu, q=1, v=1)
if colorName in colors.keys():
cmds.setAttr("{}.color".format(shader), *colors[colorName])
# A slider designed to alter the intensity of the octopus' texture
mc.intSliderGrp (label="Texture", min=0, max=10, field=True)
mc.showWindow(ram)
之后设置using System;
using System.Net.Mail;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
MailMessage mail = new MailMessage();
using (var smtpobj = new SmtpClient("smtp.gmail.com"))
{
mail.To.Add("xxx@gmail.com");
mail.From = new MailAddress("yyy@gmail.com");
mail.Subject = "subject - .net app";
mail.Body = "body";
smtpobj.Port = 587;
smtpobj.Credentials = new System.Net.NetworkCredential("yyy@gmail.com", "xyz");
smtpobj.EnableSsl = true;
smtpobj.Send(mail);
smtpobj.ServicePoint.CloseConnectionGroup(
smtpobj.ServicePoint.ConnectionName);
}
}
catch(Exception ex)
{
string strReturn = ex.ToString();
MessageBox.Show(strReturn);
}
}
}
}
,如下所示: -
layoutManager
错误将被删除!!